Skip to content

Conversation

@AshokThangavel
Copy link

Fix: Resolve <UNDEFINED> Error in generate WebApp Processing

Fixes #969

This Pull Request addresses a bug in the generate command that caused the command to fail when a user attempted to specify a web application path during module creation.

📝 Bug Summary

The generate command, which relies on the %IPM.Storage.ModuleTemplate class to process configuration, failed with an <UNDEFINED> error when the user provided input for the prompt. The error prevented the module template from being successfully created whenever web application properties were involved.

Original Error Trace:

ERROR! ObjectScript error: <UNDEFINED>AddWebApps+13^%IPM.Storage.ModuleTemplate.1 *props("Name")

🛠️ Key Fix

The issue was traced to the AddWebApps method within %IPM.Storage.ModuleTemplate. The fix involves ensuring that all required properties within the method are correctly defined and initialized before any attempt is made to access or process them.

The code is now robust against missing or improperly structured input variables during the web app configuration phase.

🧪 Unit Test Verification

The bug fix was validated using a targeted unit test that directly called the failing method with the problematic input.

Action Status Description Location
AssertStatusOK passed AddWebApps method must now process web app list without error. TestFixUndefinedCLIGenCommand+5^Test.PM.Unit.Module.cls

This confirms that the AddWebApps method now processes the web application list correctly and returns an OK status, resolving the <UNDEFINED> error in isolation.

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 The fix looks good to me! Please add a corresponding changelog entry and then I will approve

@AshokThangavel
Copy link
Author

Great, thank you for the review. I’ve added the corresponding changelog entry.

isc-kiyer
isc-kiyer previously approved these changes Nov 25, 2025
set tPath = props("Path")
}else{
set tAppName = $listget(tAppList,i)
set tAutheEnabled = 64 //Unauthenticated
Copy link
Contributor

Choose a reason for hiding this comment

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

If we must have a default, I'd prefer 32 (password) over 64 (unauthenticated) - also consider using macros from %sySecurity.inc

Copy link
Contributor

Choose a reason for hiding this comment

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

(e.g., $$$AuthePassword)

Copy link
Author

Choose a reason for hiding this comment

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

Thank you! Fixed: I've applied the fix, updating the default authentication preference (32 over 64) and converting the values to use system macros.

set ..TemplateResources(tAppName,"PasswordAuthEnabled") = 1
} elseif ( props("AutheEnabled") = 64 ) {
} elseif ( tAutheEnabled = 64 ) {
set ..TemplateResources(tAppName,"UnauthenticatedEnabled") = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth fixing this typo while we're at it - if tAutheEnabled = 64 we should set UnauthenticatedEnabled, not PasswordAuthEnabled!

Copy link
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 corrected the logic.


new $namespace
set $namespace = "%SYS"
set (tMatchRoles,tDispatchClass,tAutheEnabled,tPath)=""
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: for net new code, we do not use t-prefixes. So these should be defined as matchRoles, dispatchClass, etc

Copy link
Author

Choose a reason for hiding this comment

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

Removed the t prefix from variable names.
Thanks!

set tAutheEnabled = props("AutheEnabled")
set tDispatchClass = props("DispatchClass")
set tPath = props("Path")
}else{
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: conventionally there should be a space before and after else

Copy link
Author

Choose a reason for hiding this comment

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

I’ve fixed the spacing around else to follow the convention.


Method TestFixUndefinedCLIGenCommand()
{
set tWebAppList = "/test/test"
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: more t prefixes

Copy link
Author

Choose a reason for hiding this comment

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

Removed the t prefix from variable names.

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.

Bug: <UNDEFINED> error when generating module with Web Application input

4 participants