You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a user, when I run a cli command with an expected error returned, I should only receive the error once without the cobra help menu being displayed
Background
When localgalasactl resources apply -f invalidYamlFile.yaml --log - is run, (where invalidYamlFile.yaml should return errors), the error expected is printed twice, and the cobra help menu is printed as well.
It is suspected that the RunE function when creating cobra commands causes the cobra help menu to be displayed
It is suspected that the finalWordHandler prints the error again, hence the second error statement.
savvas@BugsLife cli % localgalasactl resources apply -f properties.yaml
Error: GAL1114E: The endpoint has responded with the following errors:
GAL5400E: Error occured when trying to execute request '{"apiversion":"galasa-dev/v1alpha1","data":{"value":"strawberry"},"kind":"GalasaProperty","metadata":{"name":"doughnutfilling","namespace":"framework"}}'. Please check your request parameters or report the problem to your Galasa Ecosystem owner.
GAL5024E: Error occured because the Galasa Property is invalid. The 'namespace' field 'null' is not structured properly.
GAL5024E: Error occured because the Galasa Property is invalid. The 'value' field 'null' is not structured properly.
Usage:
galasactl resources apply [flags]
Aliases:
apply, resources apply
Flags:
-h, --help Displays the options for the resources apply command.
Global Flags:
-b, --bootstrap string Bootstrap URL. Should start with 'http://' or 'file://'. If it starts with neither, it is assumed to be a fully-qualified path. If missing, it defaults to use the 'bootstrap.properties' file in your GALASA_HOME. Example: http://example.com/bootstrap, file:///user/myuserid/.galasa/bootstrap.properties , file://C:/Users/myuserid/.galasa/bootstrap.properties
-f, --file string Fully qualified path to the file to action against the ecosystem.Example: /user/myuserid/Documents/resources.yaml , C:/Users/myuserid/Documents/resources.yaml
--galasahome string Path to a folder where Galasa will read and write files and configuration settings. The default is '${HOME}/.galasa'. This overrides the GALASA_HOME environment variable which may be set instead.
-l, --log string File to which log information will be sent. Any folder referred to must exist. An existing file will be overwritten. Specify "-" to log to stderr. Defaults to not logging.
GAL1114E: The endpoint has responded with the following errors:
GAL5400E: Error occured when trying to execute request '{"apiversion":"galasa-dev/v1alpha1","data":{"value":"strawberry"},"kind":"GalasaProperty","metadata":{"name":"doughnutfilling","namespace":"framework"}}'. Please check your request parameters or report the problem to your Galasa Ecosystem owner.
GAL5024E: Error occured because the Galasa Property is invalid. The 'namespace' field 'null' is not structured properly.
GAL5024E: Error occured because the Galasa Property is invalid. The 'value' field 'null' is not structured properly.
Tasks
Find out if RunE is really the cause of the cobra help command being printed
Change finalWordHandler so all the error handling should be within commands - less stuff on the cobra side
The text was updated successfully, but these errors were encountered:
KirbyKatcher
changed the title
CLI: Cobra commands print out error twice and disoplays help menu
Defect: CLI - Cobra commands print out error twice and disoplays help menu
Dec 1, 2023
Hmm. Setting SilenceUsage is OK, in that it supresses usage.
The trouble is with SilenceErrors. It doesn't even report errors it finds then. And errors don't exit with 1. Or return an error from the framework.
Seems they wanted to do this but were too scared of breaking users who used those APIs (we know that problem).
When cobra displays errors, it says "Error : GAL002E ..." for example. So maybe we live with that , and don't display the galasa errors again in the final word.
Story
As a user, when I run a cli command with an expected error returned, I should only receive the error once without the cobra help menu being displayed
Background
When
localgalasactl resources apply -f invalidYamlFile.yaml --log -
is run, (where invalidYamlFile.yaml should return errors), the error expected is printed twice, and the cobra help menu is printed as well.It is suspected that the
RunE
function when creating cobra commands causes the cobra help menu to be displayedIt is suspected that the finalWordHandler prints the error again, hence the second error statement.
Tasks
Find out if RunE is really the cause of the cobra help command being printed
Change finalWordHandler so all the error handling should be within commands - less stuff on the cobra side
The text was updated successfully, but these errors were encountered: