fix(delete): fail when the deletion prompt cannot be answered - #1058
Merged
Conversation
mbevc1
enabled auto-merge (squash)
July 29, 2026 17:08
Contributor
|
Claude finished @mbevc1's task in 2m 18s —— View job Review complete ✅
SummaryThis is a well-scoped, well-tested fix. The core bug — EOF being indistinguishable from a typed refusal, so a non-interactive Static analysis: What's done well
Minor observations (non-blocking, no change requested)
Nothing blocking here — clean fix, good tests, clear rationale. LGTM. 👍 |
mbevc1
pushed a commit
that referenced
this pull request
Jul 29, 2026
Review feedback on #1058: the two blank-looking inputs take different exit paths, which was deliberate but undocumented. A blank line terminated by a newline is a submitted answer and so a refusal (exit 0); blank input terminated by EOF was never submitted and errors. Say so in the doc comment and pin both in the table test. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013uJHgA1TfGX9zNqe79DWRw
`kosli delete service-account` and `kosli delete api-key` read the confirmation answer with bufio.Reader.ReadString and excluded io.EOF from the error path, so an EOF was indistinguishable from a typed refusal. When stdin is not interactive (any CI job, < /dev/null, a closed stdin) both commands printed the prompt, read EOF, reported "was cancelled." and returned nil - exit 0 without deleting anything. A pipeline that revokes credentials could not tell that the revocation had not happened, since the exit code is the only signal it consumes. EOF with nothing read means there was nobody to ask, which is not a refusal: it is now an error naming --assume-yes, so the command exits non-zero. A typed "n", any other word, or a bare Enter still cancels with exit 0, and an answer with no trailing newline (printf 'y' | kosli delete) is still honoured - ReadString returns io.EOF together with the bytes read before it. The EOF rule lives in one new shared helper, confirmDeletion, next to the other shared cmd helpers; the two per-command functions now only build their prompt. The test harness gained a stdin seam (cmdTestCase.stdin) so an answer can be typed at the prompt. Fix requests and warn instead of exiting when payload logging fails. The debug-only payload log used Logger.Error, which is log.Fatalf and so exits 1, while the message it printed said "Continuing with the request...". The message and the behaviour disagreed Fixes #1056
Review feedback on #1058: the two blank-looking inputs take different exit paths, which was deliberate but undocumented. A blank line terminated by a newline is a submitted answer and so a refusal (exit 0); blank input terminated by EOF was never submitted and errors. Say so in the doc comment and pin both in the table test.
mbevc1
force-pushed
the
20260729_delete_err
branch
from
July 29, 2026 17:19
13bdb5d to
c4ced51
Compare
JonJagger
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
kosli delete service-accountandkosli delete api-keyread the confirmation answer with bufio.Reader.ReadString and excluded io.EOF from the error path, so an EOF was indistinguishable from a typed refusal. When stdin is not interactive (any CI job, < /dev/null, a closed stdin) both commands printed the prompt, read EOF, reported "was cancelled." and returned nil - exit 0 without deleting anything. A pipeline that revokes credentials could not tell that the revocation had not happened, since the exit code is the only signal it consumes.EOF with nothing read means there was nobody to ask, which is not a refusal: it is now an error naming --assume-yes, so the command exits non-zero. A typed "n", any other word, or a bare Enter still cancels with exit 0, and an answer with no trailing newline (printf 'y' | kosli delete) is still honoured - ReadString returns io.EOF together with the bytes read before it.
The EOF rule lives in one new shared helper, confirmDeletion, next to the other shared cmd helpers; the two per-command functions now only build their prompt. The test harness gained a stdin seam (cmdTestCase.stdin) so an answer can be typed at the prompt.
Fix requests and warn instead of exiting when payload logging fails. The debug-only payload log used Logger.Error, which is log.Fatalf and so exits 1, while the message it printed said "Continuing with the request...". The message and the behaviour disagreed
Fixes #1056
Checklist
charts/k8s-reporter/) updated, if needed. Note: these changes live in a separate PR