Skip to content

Conversation

@AshokThangavel
Copy link
Contributor

Description

This PR resolves an issue where the uninstall command would proceed without a module name. In such cases, the command would default to the "implicit context" (the last active module), leading to accidental uninstallation of applications.

fixes: #1017

Verification Results

Unit Test Passed: TestUninstallWithoutModuleName

  1. Verified that uninstall (no args) now returns a NotOK status.
  2. Verified that uninstall <name> still functions correctly.

Copy link
Collaborator

@isc-kiyer isc-kiyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AshokThangavel Looks good! Few minor comments. Also, this needs a changelog update

set tModuleName = pCommandInfo("parameters","module")
set tModuleName = $get(pCommandInfo("parameters","module"))
if (tModuleName = "") {
$$$ThrowOnError($$$ERROR($$$GeneralError, "Module name is required for uninstall."))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: add to the message "when not using the -all flag"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I’ve added a comment at the top of the code to address this.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding it to the error message itself would also be handy (and I think what @isc-kiyer meant)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you. I've updated the error message to be more descriptive: A module name must be specified for uninstall unless the -all flag is used

Method TestUninstallWithoutModuleName()
{
do $$$LogMessage("Run Uninstall command with out module name")
do ..RunCommand("unsintall")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should check appropriate error was thrown

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I've updated the code based on the comments

do ..RunCommand("uninstall objectscript-math")
set exists = ##class(%IPM.Storage.Module).NameExists("objectscript-math")
do $$$AssertNotTrue(exists, "Module removed successfully.")
quit $$$OK
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: no need for a quit at the end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Removed the "quit" from the code

do $$$LogMessage("Run Uninstall command with out module name")
do ..RunCommand("unsintall")
do ..RunCommand("install objectscript-math")
set exists = ##class(%IPM.Storage.Module).NameExists("objectscript-math")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: fix spacing on this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I’ve fixed the spacing on that line.

set tModuleName = pCommandInfo("parameters","module")
set tModuleName = $get(pCommandInfo("parameters","module"))
if (tModuleName = "") {
$$$ThrowOnError($$$ERROR($$$GeneralError, "Module name is required for uninstall."))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding it to the error message itself would also be handy (and I think what @isc-kiyer meant)

}

Method RunCommand(pCommand As %String)
// This method returns the %Status for checking the success or failure of executed commands.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: method commands should use three slashes, not two

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to three slashes


Method TestUninstallWithoutModuleName()
{
do $$$LogMessage("Run Uninstall command with out module name")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit typo: "without" and not "with out"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! fixed the typo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uninstall command executes on implicit context when argument is missing

3 participants