{"record":{"id":"ea77c1ee41770f13","repo":"mastra-ai/mastra","slug":"unknown-phase-phase","errorCode":null,"errorMessage":"Unknown phase: ${phase}","messagePattern":"Unknown phase: (.+?)","errorType":"validation","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"packages/server/src/server/handlers/processors.ts","lineNumber":475,"sourceCode":"              ...baseContext,\n              systemMessages: [],\n              stepNumber: 0,\n              steps: [],\n              finishReason: 'stop',\n              toolCalls: [],\n              text: extractTextFromMessages(messages),\n              usage: { inputTokens: undefined, outputTokens: undefined, totalTokens: undefined },\n            });\n            break;\n\n          case 'outputStream':\n            // outputStream is for streaming chunks, not a simple execute\n            throw new HTTPException(400, {\n              message: 'outputStream phase cannot be executed directly. Use streaming instead.',\n            });\n\n          default:\n            throw new HTTPException(400, { message: `Unknown phase: ${phase}` });\n        }\n\n        // Process the result\n        let outputMessages = messages;\n        if (result) {\n          if (Array.isArray(result)) {\n            outputMessages = result;\n          } else if (result.get && result.get.all && typeof result.get.all.db === 'function') {\n            // It's a MessageList\n            outputMessages = result.get.all.db();\n          } else if (result.messages) {\n            outputMessages = result.messages;\n          }\n        }\n\n        return {\n          success: true,\n          phase,","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/processors.ts#L457-L493","documentation":"The phase switch has cases for input, inputStep, output, outputResult, outputStep and outputStream; anything else falls to the default branch which throws HTTP 400 'Unknown phase: <phase>'. This guards against typo'd or unsupported phase identifiers from the client.","triggerScenarios":"Sending a phase value not in the handler's switch (e.g. 'Input', 'pre-process', 'transform', or an empty string) to the processor execute endpoint.","commonSituations":"Typos or wrong casing in API calls; older client versions sending renamed phases; hand-rolled scripts guessing phase names.","solutions":["Use an exact, lowercase phase name: input, inputStep, output, outputResult, or outputStep.","Check the API route schema/OpenAPI spec for the enumerated phase values.","Update the client SDK or playground version so phase names match the server."],"exampleFix":"// before\nbody: JSON.stringify({ phase: 'Output', messages })\n// after\nbody: JSON.stringify({ phase: 'output', messages })","handlingStrategy":"validation","validationCode":"const VALID_PHASES = ['input','inputStep','output','outputResult','outputStep','outputStream'];\nif (!VALID_PHASES.includes(phase)) {\n  throw new Error(`Unknown phase \"${phase}\"; expected one of ${VALID_PHASES.join(', ')}`);\n}","typeGuard":"type Phase = 'input' | 'inputStep' | 'output' | 'outputResult' | 'outputStep' | 'outputStream';\nfunction isPhase(v: string): v is Phase {\n  return ['input','inputStep','output','outputResult','outputStep','outputStream'].includes(v);\n}","tryCatchPattern":"try {\n  await exec(id, phase, ctx);\n} catch (e) {\n  if (e instanceof HTTPException && e.status === 400 && e.message.startsWith('Unknown phase')) {\n    console.error(`Bad phase: ${e.message}. Valid: input, inputStep, output, outputResult, outputStep`);\n    return;\n  }\n  throw e;\n}","preventionTips":["Use the typed Phase union from the SDK instead of raw strings.","Validate request bodies with the route's zod/OpenAPI schema client-side.","Watch for casing: phases are all-lowercase camelCase tokens."],"tags":["http-400","processors","invalid-parameter"],"backgroundTag":"invalid-parameter-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}