feat: surface error catalogue extensions on GraphQLError
Motivation
Infrahub 1.10 introduced the error catalogue: every GraphQL error carries extensions.code (string), extensions.http_status (int) and extensions.data (typed payload). As discussed in opsmill/infrahub#9815, consumers currently have to re-parse GraphQLError message text because the SDK does not read these extensions, and the exception message embeds the full rendered query and raw error payload — which leaks large (and potentially sensitive) payloads into logs and tracebacks.
Changes
GraphQLError.details— each entry of the response'serrorsarray parsed into a structured, frozenGraphQLErrorDetail(message, cataloguecode,http_status,data,path).GraphQLError.codes— the catalogue codes present in the response.- The exception message now joins the server-provided error messages only. The executed query and variables remain available on the
query/variablesattributes but no longer appear instr(exc). The existingAn error occurred while executing the GraphQL Queryprefix is preserved so substring matches keep working. - Parsing is defensive: non-dict entries and malformed extensions degrade to message-only details instead of raising (some in-repo call sites construct
GraphQLErrorwith non-standard payloads).
Scope
This is the minimal parsing layer. Full typed binding generation from schema/error-catalogue.json (per the infp-468 spec, tracked separately for this repo) can build on GraphQLErrorDetail later.
Testing
- New unit tests cover extensions parsing, code extraction, message conciseness (query/variables never in
str(exc)), and malformed-input tolerance. invoke format lint-codeclean (ruff, ty, mypy).- Full unit suite: no new failures (the 4 failing
ctltests on a cleanstablecheckout fail identically without this change).
Summary by cubic
Exposes Infrahub GraphQL error catalogue metadata on GraphQLError and stops embedding the query and variables in exception messages. Parsing now tolerates scalar (non-list) errors, and locations remains only on the raw errors payload.
-
New Features
GraphQLError.details: list ofGraphQLErrorDetailwithmessage,code,http_status,data,path(parses defensively; accepts list or scalar errors;locationsintentionally not exposed).GraphQLError.codes: the catalogue codes present in the response.- Exception message now joins server error messages only;
queryandvariablesstay on attributes, not instr(error).
-
Migration
- If you parsed
str(GraphQLError)for queries or payloads, useerror.query,error.variables, orerror.detailsinstead.
- If you parsed