You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(http): validate the /me and usage response shapes at runtime
Extends the #266 validation layer to the account surfaces. `GET /me` is
read by three commands through the generic `client.get`, all of which
blind-cast the body:
- `auth status`/`whoami` renders `m.scopes.join(', ')` and computes
missing scopes via `m.scopes.includes(...)` with no guard, so a `/me`
body without `scopes` crashed with a raw `TypeError: Cannot read
properties of undefined (reading 'join')` (exit 1). Under
`--output json` it was worse: the renderer never ran, so the CLI
printed the partial identity and exited 0, and an agent reading
`scopes` got undefined.
- `usage` feeds `credits` / `creditsPerRun` into
`Math.floor(credits / creditsPerRun)`, so a string balance reached the
pre-flight arithmetic unchecked.
- `doctor`'s connectivity probe reads a fully-optional projection whose
local interface had already drifted from the stubbed schema
(`v3Enabled` existed on the command side only).
Adds `ME_RESPONSE_SCHEMA` and `USAGE_RESPONSE_SCHEMA`, wires the
previously-unwired `ME_IDENTITY_SCHEMA` into `doctor`, and aliases
doctor's `MeIdentity` to the schema's wire type so the two cannot drift
again. Drift now surfaces as the standard typed INTERNAL envelope naming
the mismatched field paths.
Follows the #266 policy unchanged: every object is `looseObject` so
additive server fields pass through and reach `--output json` untouched;
`env` is validated as an open string via `openWireLiteral` so a new
deployment tier cannot hard-fail; only fields that every `/me` fixture in
the suite supplies (`userId`, `keyId`, `scopes`, `env`) are required, and
the genuinely absent-safe ones (`email`, `displayName`, `v3Enabled`,
`credits`, `subPlan`, `creditsPerRun`) stay optional with no default.
Refs #277
0 commit comments