Skip to content

fix(customrun): return error when customrun is not found during delete - #3336

Merged
tekton-robot merged 1 commit into
tektoncd:mainfrom
shubhamrai9122-creator:fix-customrun-delete-exit-code
Oct 21, 2026
Merged

tekton-robot merged 1 commit into
tektoncd:mainfrom
shubhamrai9122-creator:fix-customrun-delete-exit-code

Conversation

@shubhamrai9122-creator

Copy link
Copy Markdown
Contributor

Changes

Fixes #3329

Previously, deleteCustomRuns printed a 'not found' message when customRunExists returned an error, but skipped the resource without recording the error into deleteErr. As a result, tkn customrun delete exited 0 even when specified resources were not found.

This commit records lookup errors using multierr.Append to align CustomRun delete behavior with Task and Pipeline delete:

  • Missing names still print the message and are skipped.
  • Existing names are still deleted and reported.
  • The command returns an error if any name was not found.

Submitter Checklist

  • Includes tests
  • Commit messages follow commit message best practices

Release Notes

Fix tkn customrun delete to return a non-zero exit code when a specified customrun is not found.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Oct 10, 2026
@linux-foundation-easycla

linux-foundation-easycla Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: shubhamrai9122-creator / name: shubhamrai9122-creator (6838250)

@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 10, 2026
@pratap0007

Copy link
Copy Markdown
Contributor

@shubhamrai9122-creator Thank you for the contribution, could you please sign the CLA?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix preserves successful results, propagates failures, and includes regression coverage with no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes #3329 by making tkn customrun delete return an error when a requested resource is missing, while preserving successful deletions.

Changes:

  • Accumulates lookup and deletion errors.
  • Strengthens error assertions and adds regression coverage for mixed successful and missing resources.
File Description
pkg/​cmd/​customrun/​delete.go Collects errors without stopping successful deletions.
pkg/​cmd/​customrun/​delete_test.go Updates error expectations and tests partial success with JSON output.

Review effort: Balanced

@shubhamrai9122-creator

Copy link
Copy Markdown
Contributor Author

@pratap0007 Thanks for the review! I've signed the CLA, and the EasyCLA check is passing now. The PR is ready for another look whenever you have time.

@divyansh42

Copy link
Copy Markdown
Member

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Oct 19, 2026
Comment thread pkg/cmd/customrun/delete.go Outdated
Comment thread pkg/cmd/customrun/delete.go Outdated
Comment thread pkg/cmd/customrun/delete_test.go

@divyansh42 divyansh42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @shubhamrai9122-creator 🔥
Please squash the commits into one.

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 20, 2026
@divyansh42

Copy link
Copy Markdown
Member

/cc @pratap0007 @vdemeester

@shubhamrai9122-creator

Copy link
Copy Markdown
Contributor Author

@divyansh42 Thanks for the review! Addressed in db8fe2c:

  • Removed both inline fmt.Fprintf(s.Err, ...) prints in deleteCustomRuns. Lookup and delete failures are now reported once, through the returned error that Cobra prints. Non-NotFound lookup errors are no longer shown as "not found".
  • No test depended on the removed stderr text. TestCustomRunDeleteResourceNotFound now asserts that CustomRun nonexistent not found in namespace ns-1 appears exactly once in the combined output. The delete-failure test asserts the same for failed to delete CustomRun customrun-2. Before the change those messages appeared 2 and 3 times.

go test ./pkg/cmd/customrun/... and go vet pass locally.

Previously, deleteCustomRuns printed a 'not found' message when
customRunExists returned an error, but skipped the resource without
recording the error into deleteErr. As a result, tkn customrun delete
exited 0 even when specified resources were not found.

Record lookup and delete errors with multierr.Append and return them,
to align CustomRun delete behavior with Task and Pipeline delete. Each
failure is reported once, through the returned error, instead of also
being printed to stderr, so non-NotFound lookup errors are no longer
shown as "not found". The tests assert that the not found and delete
failure messages appear once in the combined output.

Fixes tektoncd#3329

Signed-off-by: shubhamrai9122-creator <shubhamrai9122@gmail.com>
@shubhamrai9122-creator
shubhamrai9122-creator force-pushed the fix-customrun-delete-exit-code branch from db8fe2c to 75a782c Compare October 20, 2026 13:43

@vdemeester vdemeester left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 21, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: divyansh42, vdemeester

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:
  • OWNERS [divyansh42,vdemeester]

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

@divyansh42

Copy link
Copy Markdown
Member

/retest

@tekton-robot
tekton-robot merged commit 92a8346 into tektoncd:main Oct 21, 2026
18 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tkn customrun delete exits 0 and silently succeeds when resource is not found

6 participants