Skip to content

upstream: [graphql] Port header map ordering fix and clever error codes (#10835) - #12643

Open
lollobene wants to merge 3 commits into
vm-lang/upstream/mainnet-1.47.1-1.50.1from
vm-lang/upstream/10835-graphql-clever-errors
Open

upstream: [graphql] Port header map ordering fix and clever error codes (#10835)#12643
lollobene wants to merge 3 commits into
vm-lang/upstream/mainnet-1.47.1-1.50.1from
vm-lang/upstream/10835-graphql-clever-errors

Conversation

@lollobene

@lollobene lollobene commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description of change

Ports two upstream GraphQL commits:

  • Print the GraphQL response headers of run-graphql transactional tests through a BTreeMap, so the snapshot output is deterministically ordered.
  • Resolve the error code of a clever error: it is now part of the rendered abort message and exposed as a new abortCode field on TransactionBlockEffects.

Upstream commits

Commit Upstream PR Description
e200e730a14d0bb044ac6b05c7294cd3685f6809 #21939 [graphql] Fix header map ordering in transactional-test-runner
fa4fe8341d5d4af735daebf8fe7984f257121df7 #21941 [graphql] Add error code to graphql clever error

Downstream adaptations

Upstream Downstream Reason
second header-printing site in test_adapter.rs not ported it belongs to upstream's JSON-RPC transactional subcommand; IOTA's test runner only has RunGraphqlCommand
crates/iota-indexer-alt-e2e-tests/tests/jsonrpc/test_framework/framework.snap not ported crate does not exist in IOTA
abort message rendering in iota-graphql-rpc/src/types/transaction_block_effects.rs IotaExecutionStatus::from_native_with_clever_error in crates/iota-json-rpc-types/src/iota_transaction.rs IOTA renders clever errors in one shared place (used by GraphQL, JSON-RPC and the indexer) instead of duplicating it in the GraphQL layer. The rendered strings are identical to upstream's; upstream's switch from format! to write! was not needed because the shared function does not return a Result.
resolve_native_status_impl(resolver) in the new abortCode resolver self.native().status() IOTA has no such helper; this is what the neighbouring errors resolver uses
ExecutionFailureStatus::MoveAbort(loc, code) ExecutionFailureStatus::MoveAbort { location, code } + ModuleId::new(...) IOTA uses the SDK's ExecutionError shape, which keeps package and module separate
tests/stable/errors/clever_errors.move, tests/stable/call/simple.snap tests/errors/…, tests/call/… IOTA has no stable/ test directory
staging.graphql, snapshot_tests__staging.graphql.snap not ported IOTA has no staging schema
snapshot_tests__schema.graphql.snap snapshot_tests__schema_sdl_export.snap different snapshot test name downstream

Snapshots and schema.graphql were regenerated locally (they are filtered out of the upstream patches).

Notes for the reviewer

One commit per upstream patch; both were applied with git apply first and every deviation is listed in the table above.

e200e730 — header map ordering

  • test_adapter.rs: run-graphql --show-headers printed http::HeaderMap's Debug, whose order follows the map's internal hash table and is therefore not stable across runs. It now collects into a BTreeMap<String, HeaderValue>, so the output is sorted by header name.
  • tests/call/simple.snap: the only change is the five header lines being reordered alphabetically, values untouched.

fa4fe834 — error code in clever errors

  • iota-package-resolver: CleverError gains error_code: Option<u8>, taken from ErrorBitset::error_code() (already available downstream). It is None for #[error] constants that declare no code.
  • iota-json-rpc-types: the downstream home of the message rendering that upstream changed inline in the GraphQL resolver. Two behaviour changes: the abort gets a (code = N) suffix when the constant declares a code, and the ordinal suffix no longer yields 11st/12nd/13rd. The existing format! composition was kept rather than upstream's write! rewrite (which upstream needed only for ? on fmt::Error); the resulting strings are identical to upstream's, checked literal by literal.
  • iota-graphql-rpc: the new abortCode field, falling back to the raw abort code when the abort is not a clever error — so normalAbort reports 0, as upstream.
  • clever_errors.move / .snap: two new tasks (callStringWithCode for #[error(code=1)], callNoCodeOrConst for a bare abort) plus abortCode in both queries. The large snapshot churn follows from those two tasks: task numbers, source line numbers, published package IDs and gas costs all shift, because clever-error abort codes encode the source line number and the module bytes changed.

Worth a closer look:

  • The decision to change the shared renderer: (code = N) therefore also appears in JSON-RPC and indexer responses, not only in GraphQL as upstream. The CLI is unaffected — its clever_errors fixture declares no coded constants and cli_tests__clever_errors.snap is unchanged.
  • clever_errors.snap: that the only semantic additions are the two new tasks, the abortCode values, and the abort(code = 1) message for callStringWithCode.

Links to any relevant issues

Closes #10835

How the change has been tested

  • Basic tests (linting, compilation, formatting, unit/integration tests)

  • Patch-specific tests (correctness, functionality coverage)

  • I have added tests that prove my fix is effective or that my feature works

  • I have checked that new and existing unit tests pass locally with my changes

  • cargo check --workspace --all-targets, cargo ci-clippy, cargo ci-license, cargo machete, cargo +nightly fmt --all

  • cargo nextest run -p iota-package-resolver -p iota-json-rpc-types -p iota-graphql-rpc

  • cargo test -p iota-graphql-e2e-tests --features pg_integration against a local Postgres, including the regenerated errors/clever_errors.snap and call/simple.snap

  • cargo test -p iota-graphql-rpc --test snapshot_tests (regenerated schema.graphql and its snapshot)

Release Notes

  • Indexer: Clever error messages now include the error code of the abort, if the abort constant declares one, and the command ordinal no longer renders as 11st/12nd/13rd.
  • JSON-RPC: Clever error messages now include the error code of the abort, if the abort constant declares one, and the command ordinal no longer renders as 11st/12nd/13rd.
  • GraphQL: Added TransactionBlockEffects.abortCode; clever error messages now include the error code of the abort, if the abort constant declares one, and the command ordinal no longer renders as 11st/12nd/13rd.

@lollobene
lollobene requested review from a team as code owners August 12, 2026 08:24
@iota-ci iota-ci added sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team labels Aug 12, 2026
@lollobene
lollobene marked this pull request as draft August 12, 2026 08:33
@lollobene lollobene self-assigned this Aug 12, 2026
@lollobene
lollobene marked this pull request as ready for review August 12, 2026 13:33
Comment thread crates/iota-json-rpc-types/src/iota_transaction.rs
Comment thread crates/iota-json-rpc-types/src/iota_transaction.rs
@lollobene
lollobene requested a review from a team as a code owner August 14, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sc-platform Issues related to the Smart Contract Platform group. vm-language Issues related to the VM & Language Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[tx-test-runner] Port upstream GraphQL transactional-test-runner fix and error codes

5 participants