Skip to content

refactor(delete): clean up error handling and validation - #3658

Merged
knative-prow[bot] merged 1 commit into
knative:mainfrom
xenonnn4w:funcdelrefactor
May 7, 2026
Merged

knative-prow[bot] merged 1 commit into
knative:mainfrom
xenonnn4w:funcdelrefactor

Conversation

@xenonnn4w

@xenonnn4w xenonnn4w commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Changes

  • add wrapDeleteError to unify delete-specific error handling
  • move delete error types to cmd/errors.go
  • implement Unwrap() for errors.Is/As compatibility
  • use NewErrNotInitializedFromPath for delete command
  • introduce shared ErrNameAndPathConflict (reuse across delete and describe)
  • simplify delete command flow
  • update and add tests for validation and edge cases

Tests

  • Updated:
    • TestDelete_NameAndPathExclusivity to assert ErrNameAndPathConflict
  • Added:
    • TestDelete_NoFunctionAtPath

/kind cleanup

Release Note

Refactored delete command error handling for consistency and improved validation messages.

@knative-prow knative-prow Bot added the kind/cleanup Cleanup label May 5, 2026
@knative-prow
knative-prow Bot requested review from dsimansk and jrangelramos May 5, 2026 13:48
@knative-prow knative-prow Bot added needs-ok-to-test πŸ€– Needs an org member to approve testing size/L πŸ€– PR changes 100-499 lines, ignoring generated files. labels May 5, 2026
@knative-prow

knative-prow Bot commented May 5, 2026

Copy link
Copy Markdown

Hi @xenonnn4w. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@codecov

codecov Bot commented May 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 39.50617% with 49 lines in your changes missing coverage. Please review.
βœ… Project coverage is 56.70%. Comparing base (5e9d6f8) to head (4117fc5).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
cmd/errors.go 37.17% 46 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3658      +/-   ##
==========================================
+ Coverage   53.33%   56.70%   +3.37%     
==========================================
  Files         181      181              
  Lines       20671    20784     +113     
==========================================
+ Hits        11025    11786     +761     
+ Misses       8573     7787     -786     
- Partials     1073     1211     +138     
Flag Coverage Ξ”
e2e 36.23% <4.93%> (-0.07%) ⬇️
e2e go 32.92% <0.00%> (?)
e2e node 28.63% <0.00%> (?)
e2e python 33.29% <0.00%> (?)
e2e quarkus 28.77% <0.00%> (?)
e2e rust 28.17% <0.00%> (?)
e2e springboot 26.66% <0.00%> (?)
e2e typescript 28.76% <0.00%> (?)
e2e-config-ci 17.97% <0.00%> (-0.10%) ⬇️
integration 17.42% <0.00%> (?)
unit macos-14 44.30% <40.98%> (+0.69%) ⬆️
unit macos-latest 44.30% <40.98%> (+0.69%) ⬆️
unit ubuntu-24.04-arm 44.48% <39.50%> (+0.68%) ⬆️
unit ubuntu-latest 45.16% <40.98%> (+0.69%) ⬆️
unit windows-latest 44.28% <40.98%> (+0.64%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Sentry.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gauron99

gauron99 commented May 6, 2026

Copy link
Copy Markdown
Contributor

thanks for the contribution! This is a nice change, however to the underlying issue -- this is only part of the solution I had in mind. It wasnt exactly a well-written issue to be picked up, hence I assigned myself, sorry πŸ˜„
Therefore I would like to keep the issue open. If you want we can split the issue in 2 -> error handling (what you did) and code improvements (what I need to think through how to do)

@gauron99 gauron99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just a nit from me

Comment thread cmd/errors.go Outdated
Comment thread cmd/errors.go Outdated
Comment thread cmd/errors.go Outdated
Comment thread cmd/errors.go Outdated
Comment thread cmd/errors.go Outdated
Comment thread cmd/errors.go Outdated
@gauron99

gauron99 commented May 6, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@knative-prow knative-prow Bot added ok-to-test πŸ€– Non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test πŸ€– Needs an org member to approve testing labels May 6, 2026
- centralize delete error handling via wrapDeleteError
- move and standardize delete error types
- improve not-initialized behavior for delete
- reuse ErrNameAndPathConflict across commands
@xenonnn4w

Copy link
Copy Markdown
Contributor Author

Thank you for the review. I have applied your suggestion regarding uniformity! Also i will do a comment under the issue mentioning what is achieved under this pr so you edit the issue as per time in regard of "code improvements (what I need to think through how to do)" or i'll look more into it and confirm what my views on code improvements!

@gauron99

gauron99 commented May 7, 2026

Copy link
Copy Markdown
Contributor

/lgtm
/approve

@knative-prow knative-prow Bot added the lgtm πŸ€– PR is ready to be merged. label May 7, 2026
@knative-prow

knative-prow Bot commented May 7, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, xenonnn4w

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow Bot added the approved πŸ€– PR has been approved by an approver from all required OWNERS files. label May 7, 2026
@knative-prow
knative-prow Bot merged commit 7997f0e into knative:main May 7, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved πŸ€– PR has been approved by an approver from all required OWNERS files. kind/cleanup Cleanup lgtm πŸ€– PR is ready to be merged. ok-to-test πŸ€– Non-member PR verified by an org member that is safe to test. size/L πŸ€– PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants