-
Notifications
You must be signed in to change notification settings - Fork 24
fix(shell): prevent crash when target namespace lacks IPM mappings #994
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
base: main
Are you sure you want to change the base?
fix(shell): prevent crash when target namespace lacks IPM mappings #994
Conversation
isc-kiyer
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.
@AshokThangavel few small comments but fix looks good!
src/cls/IPM/Main.cls
Outdated
| try { | ||
| set $namespace = name | ||
| if '..IsIPMEnabled(name) { | ||
| write $$$FormattedLine($$$Red," IPM is not enabled in this namespace.") |
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.
Include name in the message
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.
Included the name in the message!
src/cls/IPM/Main.cls
Outdated
| set $namespace = $select($data(list(value), ns): $listget(ns), 1: value) | ||
| set selectedNamespace = $select($data(list(value), ns): $listget(ns), 1: value) | ||
| if '..IsIPMEnabled(selectedNamespace) { | ||
| write $$$FormattedLine($$$Red," IPM is not enabled in this namespace.") |
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.
Nit: include name in message. Also, is the space before the word "IPM" intentional?
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.
Thank you for the feed back!.
Yes, the space before “IPM” is intentional. The message is displayed on the same line after the namespace selection. Without the space, it would appear as:
Enter number or name where to go: 1IPM is not enabled in this %SYS namespace.
By adding the space, the message is displayed clearly as:
Enter number or name where to go: 1 IPM is not enabled in this %SYS namespace.
| set selectedNamespace = $select($data(list(value), ns): $listget(ns), 1: value) | ||
| if '..IsIPMEnabled(selectedNamespace) { | ||
| write $$$FormattedLine($$$Red," IPM is not enabled in this namespace.") | ||
| hang 0.5 |
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.
What is the purpose of the hang? Its generally not great practice to have hangs (exceptions are for polling purposes)
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.
Hi @isc-kiyer
The purpose of the hang is to ensure the error message is visible to the user. Without the hang, the message IPM is not enabled in this namespace disappears immediately. Adding a 0.5-second hang allows the message to be displayed long enough for the user to notice and read it.
src/cls/IPM/Main.cls
Outdated
| if '..IsIPMEnabled(selectedNamespace) { | ||
| write $$$FormattedLine($$$Red," IPM is not enabled in this namespace.") | ||
| hang 0.5 | ||
| write $char(13),*27,"[K",*27,"[A" |
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.
Please add a comment if writing out unicode chars. We have the $$$FormattedLine and other macros that add semantic meaning to the chars so see if any of those suffice/add to them (I notice the same pattern is used below so worth fixing it there too)
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.
The Unicode escape sequences are used to clear the current line after displaying the error message. Without clearing the line, the message would be repeatedly printed below the prompt, resulting in output such as:
Enter number or name where to go: 1 IPM is not enabled in this %SYS namespace.
Enter number or name where to go: 1 IPM is not enabled in this %SYS namespace.
Since there were no existing macros for clearing the current line, I created a macro ($$$ClearLineAndMoveUp) to encapsulate this behavior. This adds semantic meaning to the escape sequences
This PR resolves a terminal crash occurring within the
zn(namespace) command utility. The error was triggered when the utility attempted to list or switch to namespaces where the IPM/ZPM package classes were not mapped or enabled.The crash happened specifically because the
zntool's display logic attempted to pull UI configurationRelated Issues
Changes
IsIPMEnabled) to verify if IPM classes are available in a target namespace before attempting to access them.zn *andzn [pattern]output to explicitly mark namespaces that do not have IPM enabled with a(IPM not enabled)label. This improves the user experience by clarifying why certain IPM features might be unavailable after switching.Testing Conducted
zn *and verified that namespaces like%SYSandUSERare listed with the(IPM not enabled)suffix without throwing an error.zn %SYSfrom the IPM shell. Verified that the switch completes and the prompt handles the missing class context correctly.zn %S*) still works and filters the list as expected without crashing.