Skip to content

feat(gateway): code and report a refused mint - #1222

Open
brandonleung wants to merge 3 commits into
brandon/wizard-w1-1-drop-legacy-posturefrom
brandon/wizard-w1-2-mint-refusal-code
Open

feat(gateway): code and report a refused mint#1222
brandonleung wants to merge 3 commits into
brandon/wizard-w1-1-drop-legacy-posturefrom
brandon/wizard-w1-2-mint-refusal-code

Conversation

@brandonleung

@brandonleung brandonleung commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

A refused mint reaches the user as "Something went wrong", and nothing records that it happened, so the refusals this stack adds server-side are invisible from the client.

Changes

The refusal gets a code, a message, and an event.

  • New gateway error group with GatewayMintRefused and GatewayMintFailed; the refusal carries its status and outcome so the abort path resolves it instead of the generic unhandled code.
  • Both runners print the server's message on its own, without the generic wrapper.
  • gateway mint refused is captured with status, outcome and program.
  • The outcome is read from the body's code first, then outcome: the server's exception layer flattens a dict detail, so that is where the machine-readable value lands. A code that cleans to nothing does not shadow a usable outcome.

Test plan

pnpm test. Precedence is pinned by fixtures carrying one key each, plus the empty and control-only cases; the degraded bodies (non-JSON, empty, neither key, oversized, non-string) each have a case.

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@brandonleung
brandonleung force-pushed the brandon/wizard-w1-2-mint-refusal-code branch 3 times, most recently from ebe3b05 to 0b01601 Compare September 8, 2026 20:45
@brandonleung
brandonleung force-pushed the brandon/wizard-w1-2-mint-refusal-code branch from 0b01601 to 6aa520c Compare September 8, 2026 20:57
@brandonleung
brandonleung marked this pull request as ready for review September 8, 2026 21:15
@brandonleung
brandonleung requested a review from a team as a code owner September 8, 2026 21:15

@gewenyu99 gewenyu99 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay hot take, prob doesn't matter. If we log mint refuse reason on the server with session attached, there is no reason to even send it to the client. They don't need to know if it's not actionable. For mint refuses, we gotta think about this.

Anything related to hitting limit and with an actionable please try again in time is fine. Anything else basically don't bother

brandonleung and others added 3 commits September 8, 2026 19:22
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
typeof body.code === 'string' is true for the empty string, so a refusal
carrying both keys lost its outcome whenever the code cleaned to nothing.
The catalog doc gains the group this PR adds, and the precedence has
fixtures that carry one key each, so swapping the arms goes red.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@brandonleung
brandonleung force-pushed the brandon/wizard-w1-2-mint-refusal-code branch from 6aa520c to eb9e605 Compare September 8, 2026 23:23
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.

2 participants