Skip to content

Fix GET_ACCOUNT_WITH_TOKEN type + refresh schema snapshot#26

Merged
dkijania merged 3 commits into
masterfrom
fix/account-with-token-and-schema-refresh
May 27, 2026
Merged

Fix GET_ACCOUNT_WITH_TOKEN type + refresh schema snapshot#26
dkijania merged 3 commits into
masterfrom
fix/account-with-token-and-schema-refresh

Conversation

@dkijania
Copy link
Copy Markdown
Member

Summary

Two small data fixes the new drift check (follow-up PR) caught:

  1. GET_ACCOUNT_WITH_TOKEN: \$token: UInt64!\$token: TokenId!. The daemon's account(token:) field has always expected a TokenId; any caller passing a non-empty token would get Argument 'token' of type 'TokenId' expected on field 'account', found "...".
  2. src/mina_sdk/schema/graphql_schema.json: refreshed against devnet. Previous snapshot was stale by 49 introspection diffs (mostly ofType nullability normalization on list-typed fields). No SDK behavior change.

A second PR (stacked on this branch) adds the upgraded two-layer drift checker that surfaced these.

Test plan

  • python scripts/check_schema_drift.py --endpoint <lightnet> on this branch: schema diff goes from 49 → 0.
  • Manual account(publicKey:, token:) GraphQL request with TokenId against lightnet succeeds (no value-coercion error).

🤖 Generated with Claude Code

dkijania and others added 2 commits May 27, 2026 11:39
- GET_ACCOUNT_WITH_TOKEN: change `$token: UInt64!` to `$token: TokenId!`.
  The Mina daemon's account(token:) field has always expected a TokenId
  scalar. The drift check (added in the follow-up PR) catches this
  against a live lightnet daemon.

- src/mina_sdk/schema/graphql_schema.json: regenerated against devnet.
  The previous snapshot was stale by ~49 introspection diffs (mostly
  ofType nullability normalization on list-typed fields). No SDK
  behavior change; only a fresh local schema for the drift checker
  to compare against.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two-layer schema-drift checker for the SDK:

1. Introspection diff: compare src/mina_sdk/schema/graphql_schema.json
   to the live __schema; now also detects argument-type changes
   (e.g. UInt64 -> TokenId) and inputField-type changes that the
   previous version silently passed.

2. Live query check: parse src/mina_sdk/daemon/queries.py, send each
   operation with sentinel variables, classify GraphQL errors as
   either schema drift (parse/validation) or runtime (auth, value-
   validation). Drift patterns are matched against the message
   BEFORE the path-based runtime fallback - Mina attaches `path` to
   many validation errors, so a path-first short-circuit silently
   drops real drift to the runtime bucket. Bare "expected type"
   was removed from drift patterns (false-positives on value
   coercion); a regex for the "expected on field X, found Y"
   shape now routes those to runtime explicitly.

Hardening from internal review:
- httpx.Client with 30s timeout (was bare httpx.post call per request)
- HTTP status check (non-2xx -> error; was relying on raise_for_status
  in one path and silently treating empty errors[] as OK in another)
- normalize_schema raises on error envelopes - no silent fake-empty
  schema that then flags every type as REMOVED
- _name_of sort key safe against null / non-dict entries
- kind nil-guard avoids spurious "<None> -> X" diffs
- _OP_RE filters to bodies that actually start with an operation
  keyword, so unrelated triple-quoted constants don't get probed
- _VARS_RE anchored to body start, so inner field-arg parens like
  `bestChain(maxLength: 1)` can't bind
- Connection / HTTP errors counted as infra failures, not "drift";
  always exits 1 (we can't trust the result either way)
- SKIPped ops (stale sentinel table) fail in --strict

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drift check: harden classifier and add coverage/infra-failure buckets
@dkijania dkijania merged commit aa96945 into master May 27, 2026
12 checks passed
@dkijania dkijania deleted the fix/account-with-token-and-schema-refresh branch May 27, 2026 19:29
@dkijania dkijania mentioned this pull request May 27, 2026
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.

1 participant