Description
The write() function in cmd/format.go (line 46) uses panic(err) when it encounters either an unrecognized output format name or a serialization error. This crashes the CLI process instead of showing a graceful error message via cobra's error handling.
This is the only panic in the cmd/ package outside of test code and the fundamentally-unrecoverable effectivePath() function.
Compounding issue
cmd/list.go (line 71) advertises xml as a valid output format in its --output flag help text:
Output format (human|plain|json|xml|yaml)
But there is no XML case in the write() switch, no XML() method on the Formatter interface, and no XML constant. Running func list --output xml triggers the panic and crashes.
Expected Behavior
- Invalid
--output values should produce a graceful error message
- The help text should only list actually-implemented formats
Steps to Reproduce
�ash func list --output xml # panics func list --output typo # also panics func describe --output bad # also panics
Proposed Fix
- Change
write() to return error instead of panicking
- Update all callers (
list, describe, version) to propagate the error
- Remove
xml from list command's --output flag help text
/kind bug
Description
The
write()function incmd/format.go(line 46) usespanic(err)when it encounters either an unrecognized output format name or a serialization error. This crashes the CLI process instead of showing a graceful error message via cobra's error handling.This is the only
panicin thecmd/package outside of test code and the fundamentally-unrecoverableeffectivePath()function.Compounding issue
cmd/list.go(line 71) advertisesxmlas a valid output format in its--outputflag help text:Output format (human|plain|json|xml|yaml)But there is no
XMLcase in thewrite()switch, noXML()method on theFormatterinterface, and noXMLconstant. Runningfunc list --output xmltriggers the panic and crashes.Expected Behavior
--outputvalues should produce a graceful error messageSteps to Reproduce
�ash func list --output xml # panics func list --output typo # also panics func describe --output bad # also panicsProposed Fix
write()to returnerrorinstead of panickinglist,describe,version) to propagate the errorxmlfromlistcommand's--outputflag help text/kind bug