fix: oa validate accepts a bare spec path (#94) - #98
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
oa validate <spec.yaml> failed with "No such command '<path>'" because validate is a command group and a bare positional is resolved as a subcommand name. A custom group now rewrites a leading *.yaml/*.yml token that isn't a known subcommand to --spec before parsing, so the form most people reach for first just works. aac routing, --spec, and typo errors are unchanged; passing both a bare path and --spec is an explicit error; the no-such-command message now names the valid invocation forms. Note: typer vendors its own click fork, so the group raises via ctx.fail() rather than raising click.UsageError directly — the public click exception classes don't match what typer's error rendering catches.
sgriffiths
force-pushed
the
fix/94-validate-bare-path
branch
from
July 27, 2026 01:45
b6a7c1c to
29bb9fd
Compare
aswhitehouse
approved these changes
Jul 27, 2026
aswhitehouse
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at 29bb9fd. The custom group rewrite is narrowly gated to leading YAML/YML paths, preserves aac and explicit --spec routing, rejects ambiguous dual input, and improves genuine typo errors. The focused CLI tests cover the important parsing paths, and CI is green. Approved.
Contributor
Author
|
npm parity follow-up filed as #100 (bare spec path in the npm CLI, same guardrails). The no-suffix behaviour is indeed intentional — suffix-gating is what keeps |
6 tasks
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.
What changed
oa validate <spec.yaml>— the form most people reach for first — now works. Previously it failed withNo such command '<path>'becausevalidateis a command group (foroa validate aac) and Click resolves a bare positional as a subcommand name before the callback's--specoption is ever considered.The fix is a small custom
TyperGroup: a leading*.yaml/*.ymltoken that isn't a known subcommand is rewritten to--specbefore parsing. Everything else is preserved:oa validate aac(and its flags) route exactly as before — suffix-gating meansaacis never touched.oa validate --spec pathunchanged.--specis an explicit error ("not both"), rather than one silently winning.oa validate acc) or non-YAML argument still errors, and the message now names the valid forms:oa validate <spec.yaml>,oa validate --spec <path>,oa validate aac.README examples now show the shorter form as primary (with
--specnoted as still supported).One implementation note for review: the issue's sketch (an optional
typer.Argumenton the group callback) can't work — a group-level positional is consumed before subcommand resolution, so it would swallowaac. Hence the group-level rewrite instead. Also, typer ≥0.26 vendors its own click fork, so the group raises errors viactx.fail()rather than raisingclick.UsageErrordirectly — the public click exception classes don't match what typer's error rendering catches (raising the public class produces a raw traceback instead of the error panel).Why
Closes #94. With an external project about to implement against the spec, the first command a newcomer runs shouldn't dead-end with a misleading error.
How tested
pytest tests/— 513 passed, 3 skipped)tests/test_cli_validate.py, 8 cases: bare.yamlpath, bare.ymlpath,--specunchanged, both-forms error, missing-file bare path is a validation error (not "No such command"),aacstill routes, typo and non-YAML arguments name the valid formsAlso:
ruff check .clean,ruff format --checkclean,mypy oas_cliclean. Manually exercised every form against the venv-installed CLI, including--helpand no-args.Type of change
Checklist
ruff check . && ruff format --check .)