Skip to content

Overhaul flag and subcommand errors in kubectl-ate - #2547

Merged
Tim Hockin (thockin) merged 1 commit into
agent-substrate:mainfrom
thockin:cli-input-errors
Oct 15, 2026
Merged

Tim Hockin (thockin) merged 1 commit into
agent-substrate:mainfrom
thockin:cli-input-errors

Conversation

@thockin

Copy link
Copy Markdown
Collaborator

Previous to this errors might be helpful (dumping full help text) but they might also be spartan:

$ kubectl-ate dasdsd
Error: unknown command "dasdsd" for "kubectl-ate"
Run 'kubectl-ate --help' for usage.

or they might be useless:

$ kubectl-ate -r
Error: unknown shorthand flag: 'r' in -r

Sometimes they used stdout, and sometimes stderr.

In short, Cobra's error handling is a mess. There are bazillions of options and I could not find a combination that did something useful.

So now we take control ourselves. Every error should: 1) print an error message telling you what went wrong ("missing flag",
"unknown subcommand", etc)
2) dump the closest help message
3) write to stderr exclusively

This also cleans up flag descriptions.

Gemini helped.

Fixes #2463

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

@thockin

Copy link
Copy Markdown
Collaborator Author

Rebased

Comment thread cmd/kubectl-ate/internal/cmd/validation.go
Comment thread cmd/kubectl-ate/internal/cmd/validation.go Outdated
Previous to this errors might be helpful (dumping full help text) but
they might also be spartan:
```
$ kubectl-ate dasdsd
Error: unknown command "dasdsd" for "kubectl-ate"
Run 'kubectl-ate --help' for usage.
```

or they might be useless:
```
$ kubectl-ate -r
Error: unknown shorthand flag: 'r' in -r
```

Sometimes they used stdout, and sometimes stderr.

In short, Cobra's error handling is a mess.  There are bazillions of
options and I could not find a combination that did something useful.

So now we take control ourselves.  Every error should:
1) print an error message telling you what went wrong ("missing flag",
   "unknown subcommand", etc)
2) dump the closest help message
3) write to stderr exclusively

This also cleans up flag descriptions.

Gemini helped.
@thockin

Copy link
Copy Markdown
Collaborator Author

rebased and fixed (I think)

@BenTheElder
Benjamin Elder (BenTheElder) added this pull request to the merge queue Oct 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 15, 2026
@thockin
Tim Hockin (thockin) added this pull request to the merge queue Oct 15, 2026
Merged via the queue into agent-substrate:main with commit 6edd1fc Oct 15, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: kubectl ate get hides missing --atespace behind a kubeconfig error

3 participants