{"record":{"id":"59ff901bc3b6db24","repo":"mastra-ai/mastra","slug":"query-parameter-status-must-be-draft-or-publi","errorCode":null,"errorMessage":"Query parameter \"status\" must be \"draft\" or \"published\"","messagePattern":"Query parameter \"status\" must be \"draft\" or \"published\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client-sdks/ai-sdk/src/chat-route.ts","lineNumber":716,"sourceCode":"        mastra\n          .getLogger()\n          ?.warn(`Multiple \"requestContext\" sources provided. Using priority: middleware > route options > body.`);\n      }\n\n      if (!agentToUse) {\n        throw new Error('Agent ID is required');\n      }\n\n      // Resolve agent version from query params, falling back to static option\n      const queryVersionId = c.req.query('versionId');\n      const rawStatus = c.req.query('status');\n\n      if (queryVersionId && rawStatus) {\n        throw new Error('Query parameters \"versionId\" and \"status\" are mutually exclusive');\n      }\n\n      if (rawStatus && rawStatus !== 'draft' && rawStatus !== 'published') {\n        throw new Error('Query parameter \"status\" must be \"draft\" or \"published\"');\n      }\n\n      const queryStatus = rawStatus as 'draft' | 'published' | undefined;\n      const effectiveAgentVersion: AgentVersionOptions | undefined = queryVersionId\n        ? { versionId: queryVersionId }\n        : queryStatus\n          ? { status: queryStatus }\n          : agentVersion;\n\n      const handlerOptions = {\n        mastra,\n        agentId: agentToUse,\n        agentVersion: effectiveAgentVersion,\n        params: {\n          ...params,\n          requestContext: effectiveRequestContext,\n          abortSignal: c.req.raw.signal,\n        } as any,","sourceCodeStart":698,"sourceCodeEnd":734,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/client-sdks/ai-sdk/src/chat-route.ts#L698-L734","documentation":"The chatRoute rejects a request whose `status` query parameter is not exactly \"draft\" or \"published\". The route supports version selection for an agent either by explicit versionId or by channel status, and it only accepts these two literal status values; anything else is invalid input and is rejected before any agent work begins.","triggerScenarios":"Calling the chat route with a query string like ?status=latest, ?status=DRAFT, ?status=prod, or any misspelled value while versionId is not provided.","commonSituations":"Clients hardcoding a status string that drifts from the API contract (e.g. 'production' instead of 'published'), case-sensitivity mistakes, UI dropdowns emitting display labels instead of the literal values, or a stale client built against an older/looser API.","solutions":["Send only \"draft\" or \"published\" as the status query parameter value","Use lowercase, exact spelling — values are compared strictly","If you need a specific version, pass versionId instead of status (they are mutually exclusive)","URL-encode/trim whitespace; stray spaces cause the mismatch"],"exampleFix":"// before\nfetch(`/api/chat?status=production`)\n// after\nfetch(`/api/chat?status=published`)","handlingStrategy":"validation","validationCode":"const STATUS = ['draft','published'];\nfunction assertStatus(s?: string) {\n  if (s && !STATUS.includes(s)) throw new Error(`status must be \"draft\" or \"published\", got \"${s}\"`);\n}\nassertStatus(new URL(url).searchParams.get('status'));","typeGuard":"function isAgentVersionStatus(v: unknown): v is 'draft' | 'published' {\n  return v === 'draft' || v === 'published';\n}","tryCatchPattern":"try {\n  const res = await fetch(url);\n  if (!res.ok) throw new Error(await res.text());\n} catch (e) {\n  if (e.message.includes('status\" must be')) {\n    // correct the query param and retry\n  }\n}","preventionTips":["Keep a shared constant/type for allowed status values on both client and server","Validate query params in the client before building URLs","Never use UI display labels as API parameter values"],"tags":["http","query-params","validation","api-contract"],"backgroundTag":"invalid-query-parameter-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}