fix(runtime): extend usage details to body and catalog discovery errors - #172
Merged
Conversation
A generated command with a required request body and no changed body input failed with a bare invalid-command-usage message. The required-body errors in resolveOperationBody now carry a typed usage detail naming the accepted body inputs (--file, --set, --set-str, and body flags when the command has them), matching the detail contract introduced for enum and required-flag errors. The detail is static spec-derived text and echoes no user input. Signed-off-by: samzong <samzong.lu@gmail.com>
commands show with an unknown path returned a generic command-failed error with a misleading local-configuration hint and exit 1; it is a usage error and now exits 2 with a detail pointing at the commands listing, without echoing the requested path. An empty or blank search query silently exited 0 with no output, indistinguishable from zero matches; it now fails as a usage error stating the query must not be empty. Signed-off-by: samzong <samzong.lu@gmail.com>
Contributor
Merging this PR will not alter performance
|
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.
Summary
Two gaps left after #171: a required request body with no body input failed with a bare invalid-command-usage message, and the catalog discovery commands hid their failures —
commands show <unknown path>returned a generic command-failed error with a misleading local-configuration hint (exit 1), and an emptysearchquery exited 0 with no output, indistinguishable from zero matches.resolveOperationBodyrequired-body errors now carry a typed usage detail naming the accepted body inputs (--file,--set,--set-str, and body flags when present).commands showwith an unknown path is a usage error (exit 2) whose detail points at thecommandslisting without echoing the requested path.searchquery fails as a usage error stating the query must not be empty.All details are static or spec-derived text under the existing
error.detailcontract (docs/contracts.md); no user input is echoed and no contract text changes.Verification
go test ./pkg/runtime/ -run TestBuild_RequiredBodyUsageErrorDetailandgo test ./pkg/lathe/ -run 'TestCommandsShowUnknownPathUsageError|TestSearchEmptyQueryUsageError'— red before the fix, green after.make checkandgo test -race -count=1 ./...pass.Detail: request body required: pass --file, --set, --set-str, or a body flagfor barekeys create,Detail: no generated command at that path; run \tokener commands` to list paths(exit 2) forcommands show keys nope, andDetail: search query must not be emptyforsearch ""`.Compatibility
commands showwith an unknown path changes from exit 1 (command failed) to exit 2 (usage), and a blanksearchquery changes from exit 0 to exit 2. Error envelope shape, catalog schema, and the detail contract are unchanged.Checklist
internal/generated/,.cache/, and ad-hocskills/<cli-name>/directories is not committed.