fix(api-call): apply headers, error on non-2xx, GraphQL errors, output shape (DEVX-546)#97
Open
smukherjee-godaddy wants to merge 2 commits into
Open
Conversation
…t shape (DEVX-546)
`gddy api call` had five defects that made it unreliable — and left the GraphQL
commerce domains (catalog-products, taxes) uncallable:
- Headers: `--header KEY:VALUE` was parsed but never attached to the request, so
endpoints requiring a header (the GraphQL commerce domains need `x-store-id`)
could not be called. Now applied (split on first colon, trimmed).
- Non-2xx: any non-2xx status was returned as a success result carrying the error
body. Now returns an error (non-zero exit) with the status line + truncated body.
- Non-JSON body: was silently coerced to `null`. Now preserved as raw text.
- GraphQL errors: a GraphQL 200 response with a top-level `errors` array was
reported as success. Now detected (by graphql/subgraph path) and surfaced as an
error.
- Output shape: `{ status, body }` -> `{ endpoint, method, status, status_text,
data }`, matching the documented contract.
Extracted split_header / parse_response_body / graphql_errors as pure helpers with
unit tests. cargo test/clippy/fmt clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment on lines
+694
to
+697
| // Apply user-supplied `--header KEY:VALUE` values (repeatable). These | ||
| // were parsed but never attached to the request, so endpoints that | ||
| // require a header — e.g. the GraphQL commerce domains need `x-store-id` | ||
| // — could not be called at all. |
Collaborator
There was a problem hiding this comment.
No need to reference prior bugs; not useful for future readers.
Suggested change
| // Apply user-supplied `--header KEY:VALUE` values (repeatable). These | |
| // were parsed but never attached to the request, so endpoints that | |
| // require a header — e.g. the GraphQL commerce domains need `x-store-id` | |
| // — could not be called at all. | |
| // Apply user-supplied `--header KEY:VALUE` values (repeatable). |
Contributor
Author
There was a problem hiding this comment.
Updated in 68ec959. The comment now documents only the current header application behavior.
jpage-godaddy
approved these changes
Jul 14, 2026
jpage-godaddy
left a comment
Collaborator
There was a problem hiding this comment.
Just one nit here and the rest looks good.
Remove historical bug context from the inline comment so it only documents the current behavior.
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.
Problem
gddy api callhad five defects that made it unreliable — and left the GraphQL commerce domains (catalog-products,taxes) impossible to call at all:--header KEY:VALUEwas parsed but never attached to the request. Endpoints that require a header (the GraphQL commerce domains needx-store-id) could not be called.null, discarding the detail.200response with a top-levelerrorsarray was reported as success.{ status, body }instead of the documented{ endpoint, method, status, status_text, data }.Fix
--headerto the request (split on the first colon so values may contain colons; trimmed).null.graphql/subgraph) and surface a non-emptyerrors[]as an error.{ endpoint, method, status, status_text, data }(+headerswhen--include).Extracted
split_header,parse_response_body, andgraphql_errorsas pure helpers with unit tests. The existing 403-with-required-scopes hint is preserved ahead of the generic non-2xx handler.Impact
catalog-products,taxes) are now callable via--header x-store-id: <uuid>.Scope / dependency
This fixes correctness at the
api calllayer. The final envelope wrapping — success as{ ok, command, result, next_actions }on stdout and errors on stdout — is the output-contract work (DEVX-542 / DEVX-543); this PR composes with it and does not duplicate it.Companion to DEVX-548 (catalog
$refresolution): that made the commerce schemas resolvable; this makes the endpoints callable.Testing
cargo test api_explorer— 8 pass (3 new:split_header_*,parse_response_body_*,graphql_errors_*)cargo clippy --bin gddy -- -D warnings— cleancargo fmt --check— cleanNot covered here: a full
httpmock+ mock-credential integration test of the success path (api callrequires a token) — that's the T4 test in the test-layer ticket.