CLI UX: 'axon run' should validate that --prompt is not empty
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 331
- Forks
- 40
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 70
Description
Problem
The `axon run` command accepts an empty string for the required `--prompt` flag, creating invalid Tasks that will fail at the API level.
Current Behavior
# Empty prompt is accepted
axon run -p "" --secret dummy --dry-run
# Output:
apiVersion: axon.io/v1alpha1
kind: Task
metadata:
name: task-twq97
spec:
prompt: "" # Empty!
...
If submitted to the cluster (without `--dry-run`), this would fail at the Kubernetes API validation level, but only after:
- The task resource is attempted to be created
- Network round-trip to the API server
- API-level validation runs
Why This is a Problem
- Late failure: Error happens at API submission, not immediately
- Poor error location: Users don't get helpful context about which CLI flag is the problem
- Wasted resources: Unnecessary API call for an obvious client-side issue
- Incomplete client validation: The CLI marks `--prompt` as required (`cmd.MarkFlagRequired("prompt")`) but doesn't validate it's non-empty
Expected Behavior
The CLI should validate that the prompt is not empty or whitespace-only:
axon run -p "" --secret dummy
Error: --prompt cannot be empty
axon run -p " " --secret dummy
Error: --prompt cannot be empty or contain only whitespace
Impact
- Delayed error feedback: Users don't discover the issue until API submission
- Less helpful errors: API errors are less specific than CLI validation errors
- Inconsistent UX: Other validations happen client-side, but this one doesn't
Suggested Fix
Add validation in the `RunE` function after flag parsing:
prompt = strings.TrimSpace(prompt)
if prompt == "" {
return fmt.Errorf("--prompt cannot be empty")
}
This should happen early, before any resource creation logic.
Additional Context
- The prompt field is marked as required in the API: `+kubebuilder:validation:Required`
- Found during developer experience testing
- Empty validation is a common CLI pattern (e.g., git commit requires non-empty messages)
- Related to #182 (client-side validation patterns)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the axon run command's RunE function, after flag parsing and before resource creation logic. Review the existing client-side validation patterns, then run the relevant CLI tests or reproduce the empty and whitespace-only examples. Done means both inputs fail immediately with a helpful --prompt error before any API request or resource creation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100