moeru-ai/airi · error · Error

Invalid Godot stage view-state error payload.

Error message

Invalid Godot stage view-state error payload.

What it means

Thrown by parseStageViewErrorPayload when a Godot-emitted error event fails safeParse against StageViewErrorPayloadSchema. The schema is a strictObject requiring `code` to be one of 'invalid-payload' | 'invalid-state-file' | 'persistence-failed' | 'storage-root-missing' | 'view-state-unavailable', `message` to be a string, plus a `requestId`. Any unknown code, missing field, or extra key makes the parse fail — the irony being this parser handles error events themselves.

Source

Thrown at packages/stage-shared/src/godot-stage/view-state.ts:178

/** Error event emitted by Godot for view-state request, validation, or lifecycle failures. */
export interface StageViewErrorPayload {
  code: StageViewErrorCode
  message: string
  requestId?: string
}

export const StageViewErrorPayloadSchema = strictObject({
  code: picklist(['invalid-payload', 'invalid-state-file', 'persistence-failed', 'storage-root-missing', 'view-state-unavailable']),
  message: string(),
  requestId: requestIdSchema,
})

/** Parses a Godot-emitted view-state error. */
export function parseStageViewErrorPayload(payload: unknown): StageViewErrorPayload {
  const result = safeParse(StageViewErrorPayloadSchema, payload)
  if (!result.success)
    throw new Error('Invalid Godot stage view-state error payload.')

  return {
    code: result.output.code,
    message: result.output.message,
    ...(result.output.requestId != null ? { requestId: result.output.requestId } : {}),
  }
}

View on GitHub (pinned to 677329427f)

Solutions

  1. Run safeParse(StageViewErrorPayloadSchema, payload) yourself and inspect r.issues to see which field (usually `code`) is off
  2. Diff the code list in the Godot emission site against the picklist in view-state.ts and sync them in one change
  3. When adding a new code, extend both the picklist and the StageViewErrorCode union type, then rebuild both packages
  4. For forwarded errors, degrade gracefully: if parsing fails, surface the raw payload in logs rather than dropping it

Example fix

// before
const err = parseStageViewErrorPayload(payload)

// after
import { safeParse, StageViewErrorPayloadSchema } from '../godot-stage/view-state'
const r = safeParse(StageViewErrorPayloadSchema, payload)
if (!r.success) {
  // keep the raw error visible instead of failing opaquely
  console.error('unrecognized Godot view-state error payload', payload, r.issues)
} else {
  handleKnownCode(r.output.code)
}
Defensive patterns

Strategy: try-catch

Validate before calling

import { safeParse, StageViewErrorPayloadSchema } from '../godot-stage/view-state'

const ok = safeParse(StageViewErrorPayloadSchema, payload).success

Type guard

const isKnownViewErrorCode = (c: unknown): c is 'invalid-payload' | 'invalid-state-file' | 'persistence-failed' | 'storage-root-missing' | 'view-state-unavailable' => typeof c === 'string' && ['invalid-payload','invalid-state-file','persistence-failed','storage-root-missing','view-state-unavailable'].includes(c)

Try / catch

catch (e) { if (e.message.includes('view-state error payload')) { console.error('raw Godot error event (unparsed):', payload); return } throw e }

Prevention

When it happens

Trigger: The Godot side emits an error with a newly introduced code string (e.g. 'disk-full') not present in the picklist, omits `message`, or the error envelope is forwarded as a JSON string instead of an object.

Common situations: Version skew after someone adds a new StageViewErrorCode on the engine side without updating packages/stage-shared; GDScript error paths that build the table manually and typo a code ('Invalid-Payload'); tests that stub error payloads with only a message field.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of moeru-ai/airi@677329427f (2026-08-18). Data as JSON: /api/errors/e3569d5f1b7cb7b2. Report an issue: GitHub.