fix(cmd): replace panic with error return in write() and remove phantom xml format#3845
fix(cmd): replace panic with error return in write() and remove phantom xml format#3845Elvand-Lie wants to merge 2 commits into
Conversation
|
Hi @Elvand-Lie. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Elvand-Lie The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3845 +/- ##
==========================================
+ Coverage 53.44% 53.46% +0.02%
==========================================
Files 200 200
Lines 23450 23443 -7
==========================================
+ Hits 12533 12534 +1
+ Misses 9662 9657 -5
+ Partials 1255 1252 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…om xml format The write() function in format.go used panic(err) when encountering an unrecognized output format or serialization error. This crashes the CLI process instead of showing a graceful error message. Additionally, list.go advertised 'xml' as a valid output format in its --output flag help text, but XML was never implemented. Passing --output xml would trigger the panic. Changes: - Change write() to return error instead of panicking - Update all three callers (list, describe, version) to propagate the error - Remove 'xml' from list command's --output flag help text Signed-off-by: Elvand-Lie <nicholasdwiputra@gmail.com>
df84478 to
c1d3836
Compare
Fixes #3844
Changes
The
write()function incmd/format.gousedpanic(err)when encountering an unrecognized output format or serialization error. This crashes the CLI process instead of showing a graceful error message.Additionally,
list.goadvertisedxmlas a valid output format in its--outputflag help text, but XML was never implemented. Passing--output xmlwould trigger the panic.What this PR does:
cmd/format.go: Changewrite()to returnerrorinstead of panickingcmd/list.go,cmd/describe.go,cmd/version.go: Update all three callers to propagate the returned errorcmd/list.go: Removexmlfrom the--outputflag help textTesting
The change is minimal and type-safe - the function signature change from
func write(...)tofunc write(...) errorforces all callers to handle the error. Previously-panicking code paths now return errors through cobra's standard error handling./kind bug