-
Notifications
You must be signed in to change notification settings - Fork 281
(fix) O3-4898: Implementer tools: Prevent crash when hovering over tree-level descriptions #1485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(fix) O3-4898: Implementer tools: Prevent crash when hovering over tree-level descriptions #1485
Conversation
|
@denniskigen this one also |
ibacher
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we undo the changes to the en.json files, please?
.../esm-implementer-tools-app/src/configuration/interactive-editor/config-subtree.component.tsx
Outdated
Show resolved
Hide resolved
.../esm-implementer-tools-app/src/configuration/interactive-editor/config-subtree.component.tsx
Outdated
Show resolved
Hide resolved
8123176 to
e477c92
Compare
|
@ibacher i have fixed the changes you asked to do |
| .filter(([key]) => !key.startsWith('_')) | ||
| .map(([key, value], i) => { | ||
| const thisPath = path.concat([key]); | ||
| const isLeaf = Object.hasOwn(value, '_value'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const isLeaf = Object.hasOwn(value, '_value'); | |
| const isLeaf = value && typeof value === 'object' && Object.hasOwn(value, '_value'); |
Can we add a type check here before calling Object.hasOwn()? It will throw a TypeError if called on null or undefined. Without a guard, hovering over or rendering a config node with a null/undefined value will crash. With this check, value && short-circuits when value is null or undefined, so we never reach the typeof or Object.hasOwn() calls. This prevents the TypeError.
|
Tangential, but can we fix the improper use of lodash.unset() mutates the object in place and returns a boolean (true if property existed), not the modified object. The current code passes this boolean to temporaryConfigStore.setState(unset(temporaryConfigStore.getState(), ['config', ...path]) as any);This corrupts the store state. Instead, we should clone first, mutate the clone, then pass the clone to const state = cloneDeep(temporaryConfigStore.getState());
unset(state, ['config', ...path]);
temporaryConfigStore.setState(state);This follows immutable state update patterns and prevents store corruption when resetting config values to defaults. |
|
@denniskigen i have applied the changes |
|
@denniskigen sir any updates on this |
|
@denniskigen sorry to tag you again wanted to hop you up about this what else i need to do? |
- Add type checks before Object.hasOwn() to prevent TypeError on null/undefined values - Fix improper use of lodash.unset by cloning state before mutation - Follows immutable state update patterns to prevent store corruption
- Add tests to verify type guards prevent TypeError on null/undefined values - Add tests to verify immutable state update pattern with lodash.unset - Ensures changes follow best practices and prevent store corruption
… component Adds type guards for _source and _description properties to prevent runtime crashes when accessing metadata on non-leaf config nodes. Also removes unused parameters and adds explicit TypeScript type annotations for better type safety.
Converts CRLF (Windows) line endings to LF (Unix) to match repository convention.
Previous tests were not canonical and did not test the component-level behavior. Rather, they test implementation details. They also used non-canonical imports instead of Jest globals and are not colocated properly to the code they were testing.
062ebca to
d903639
Compare
|
@RajPrakash681 could you change your IDE's line endings from CRLF (Carriage Return + Line Field) to LF (Line Field) to align with the repo's conventions? That explains the spurious |
denniskigen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @RajPrakash681!
|
🤦🏼 should we revert it, @brandones? |
|
I didn't read the code, dunno what it does; up to you. I updated the ticket description to clarify that expectation. |
|
@denniskigen @brandones Sorry for any inconvenience caused by my message. I see that the crash issue has been fixed, but now the tree-level descriptions are not displaying as expected, I am happy to look into fixing this display issue with the higher-level descriptions in the Implementer Tools. Please confirm if you would like me to take this up, and if you can provide any additional details or test cases that I should consider when working on this fix. |
|
also,Also, I didn’t expect this issue to occur because all the tests were passing earlier in the same manner. Sorry for the unexpected problem and any confusion it may have caused. |
|
@RajPrakash681 please see the ticket description and my screenshot above. If it is clear to you what is being asked, then yes please go ahead and fix it. If not, ask a clarifying question.
The tests were also passing when the bug was causing the UI to crash completely. I see you wrote a test that has nothing to do with the problem (no mention of This is a large, complex application, and you can't expect to just throw AI at it and get correct results. You have to try to understand it a little bit, at least the little piece you're working on. |
|
also I promise to be more thorough in understanding the requirements and testing my changes properly before submitting. Issues like this won't happen again from my side - I'll make sure to always verify the feature works end-to-end in the UI, not just that the code compiles. I'll update here once I have a proper fix ready for review. |
@denniskigen i can see the description |
It's the descriptions of upper-level elements (so in that example, |




Requirements
feat,fix, orchore, among others). See existing PR titles for inspiration.If applicable
Summary
This PR fixes a crash in the Implementer Tools that occurred when hovering over configuration nodes that have
_descriptionat the tree level (for parent/container nodes) instead of only at the leaf level.Problem
The OpenMRS config system supports descriptions at both tree and leaf levels:
foo: { _description: "Controls the big Foo thing", bar: {...} }foo: { _description: "A setting", _value: "val", _source: "default" }However, the
ConfigSubtreecomponent was iterating over ALL keys in config objects, including metadata keys like_description,_validators,_type, etc., and trying to render them as config tree nodes. When it encountered a tree-level_description, it would:_descriptionas a config property nodeObject.entries("string value")which causes unexpected behavior and crashesIssue
https://openmrs.atlassian.net/browse/O3-4898