Skip to content

fix: Validate required schema fields when no input is provided#125

Merged
JoshMock merged 2 commits into
mainfrom
MattDevy/fix/issue-96
Apr 13, 2026
Merged

fix: Validate required schema fields when no input is provided#125
JoshMock merged 2 commits into
mainfrom
MattDevy/fix/issue-96

Conversation

@MattDevy

Copy link
Copy Markdown
Contributor

Summary

  • When a command has a Zod input schema but the user provides no input (no --input-file, no stdin, no CLI args), inputValue remained undefined and validation was skipped entirely. This caused literal {param} placeholders to be sent in URLs to Elasticsearch.
  • Fix: default inputValue to {} when undefined so Zod validation always runs, catching missing required fields before the handler executes.
  • Implements option 2 from Required schema args not enforced: unresolved path params sent as literals #96.

Closes #96
Closes #103

Test plan

  • New test: validation fails when schema has required fields but no input is provided
  • New test: handler is NOT invoked when required fields are missing
  • New test: all-optional schema succeeds with no input (no regression)
  • New test: JSON-format error output for missing required fields
  • Updated 2 existing tests that asserted the buggy behavior
  • Full test suite passes (511 tests, 0 failures)
  • Manual verification: elastic es cluster info, elastic es delete, elastic es index all return clear validation errors instead of sending literal placeholders

When a command has a Zod input schema but the user provides no input
(no --input-file, no stdin, no CLI args), inputValue remained undefined
and validation was skipped entirely. This caused literal {param}
placeholders to be sent in URLs to Elasticsearch.

Default inputValue to {} when undefined so Zod validation always runs,
catching missing required fields before the handler executes.

Closes #96
Closes #103
@MattDevy MattDevy requested review from JoshMock and flobernd April 13, 2026 12:11
@JoshMock JoshMock merged commit 6ace544 into main Apr 13, 2026
16 checks passed
@JoshMock JoshMock deleted the MattDevy/fix/issue-96 branch April 13, 2026 17:35
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.

Top level commands run even without required options Required schema args not enforced: unresolved path params sent as literals

3 participants