zowe-cli
zowe-cli copied to clipboard
`zowe plugins validate` returns always RC=0
It is not possible to use the command zowe plugins validate
to verify if the plugin is properly installed because the return code is always 0.
Example:
$ zowe plugins validate @zowe/zos-ftp-for-zowe-cli
_____ Validation results for plugin '@zowe/zos-ftp-for-zowe-cli' _____ This plugin was successfully validated. Enjoy the plugin.
$ echo $? 0
$ zowe plugins validate @zowe/zos-ftp-for-zowe-clix The specified plugin '@zowe/zos-ftp-for-zowe-clix' has not been installed into your CLI application.
$ echo $? 0
Since CLI version 6.33.0, the zowe plugins validate
command has the option --fail-on-error
that, if specified on the command, will set the return code to 1 if validation fails due to an error. The same version also introduced the option --fail-on-warning
, which sets the return code if plugin validation issues a warning, but the plugin commands are still available.
The --fail-on-error
option will become enabled by default in V2-LTS, but as it was considered to be a potential breaking change, it remains disabled by default in V1-LTS.
The problem occurs when you install new plug-ins. Even if the validation of the plugin fails, it is considered a success. And then it fails later.
Example:
- Installation of a corrupted plugin is "successful"
result: {'success': True, 'exitCode': 0, 'message': '', 'stdout': "Plug-ins within the Imperative CLI Framework can legitimately gain\ncontrol of the zowe CLI application during the execution of every command.\nInstall 3rd party plug-ins at your own risk.\n\nImperative's plugin installation program handles @zowe peer dependencies.\nYou can safely ignore NPM warnings about missing @zowe peer dependencies.\n\nRegistry = https://registry.npmjs.org/\n\n_______________________________________________________________\nInstalled plugin name = '@zowe/ansible-collection-generator'\n\n_____ Validation results for plugin '@zowe/ansible-collection-generator' _____\n\n*** CmdError: Unable to load the following module for plug-in '@zowe/ansible-collection-generator' :\n/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/plugins/installed/lib/node_modules/@zowe/ansible-collection-generator/lib/imperative.js\nReason = Cannot find module '/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/plugins/installed/lib/node_modules/@zowe/ansible-collection-generator/lib/imperative.js'\nRequire stack:\n- /private/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/node_modules/@zowe/cli/node_modules/@zowe/imperative/lib/imperative/src/plugins/PluginManagementFacility.js\n- /private/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/node_modules/@zowe/cli/node_modules/@zowe/imperative/lib/imperative/src/Imperative.js\n- /private/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/node_modules/@zowe/cli/node_modules/@zowe/imperative/lib/imperative/index.js\n- /private/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/node_modules/@zowe/cli/node_modules/@zowe/imperative/lib/index.js\n- /private/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/node_modules/@zowe/cli/lib/main.js\n\n*** CfgError: Failed to load the plugin's configuration from:\n/var/folders/n4/j9nxgl097ksb040nsvgqk50h0000gn/T/tmpzutg1gs8/plugins/installed/lib/node_modules/@zowe/ansible-collection-generator/package.json\nReason = Cannot create property 'name' on string '{}'\n\nThis plugin has configuration errors. No component of the plugin will be available.\n\n\n", 'stderr': '', 'data': {}}
- Using the command fails with:
Command failed due to improper syntax
Unknown group: ...
There is a fine line between fixing bugs and breaking changes. Fixing a bug can be seen as a change in the expected behavior for someone else. In the case of the reported problem, it seems that fixing the bug is better - the script fails anyone and it is better to fail earlier. But I do not know all other cases.
The zowe plugins install
does not --fail-on-error
option. Such option would be useful too.
The suggested fix here is to make --fail-on-error
the default behavior in the "zowe-v1-lts" branch.
@AmandaDErrico This issue could be a good one to pick up if you're looking for a CLI issue to work on 🙂
Need to test if this is already completed.