{"record":{"id":"553e826b4499ec80","repo":"linshenkx/prompt-optimizer","slug":"unsupported-garden-response-schema","errorCode":null,"errorMessage":"Unsupported Garden response schema","messagePattern":"Unsupported Garden response schema","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/composables/app/useAppPromptGardenImport.ts","lineNumber":530,"sourceCode":"\n  const resp = await fetch(url, {\n    method: 'GET',\n    headers: {\n      Accept: 'application/json'\n    }\n  })\n\n  if (!resp.ok) {\n    throw new Error(`Garden request failed: ${resp.status}`)\n  }\n  const text = await resp.text()\n\n  const parseV1 = (data: unknown): FetchedPrompt => {\n    if (!isPlainObject(data)) {\n      throw new Error('Garden response must be a JSON object')\n    }\n    if (data.schema !== 'prompt-garden.prompt.v1') {\n      throw new Error('Unsupported Garden response schema')\n    }\n    if (data.schemaVersion !== 1) {\n      throw new Error('Unsupported Garden response schemaVersion')\n    }\n\n    const optimizerTarget = isPlainObject(data.optimizerTarget) ? data.optimizerTarget : null\n    const optimizerTargetKey =\n      optimizerTarget && typeof optimizerTarget.subModeKey === 'string'\n        ? optimizerTarget.subModeKey.trim()\n        : ''\n    if (!optimizerTargetKey) {\n      throw new Error('Missing optimizerTarget.subModeKey')\n    }\n\n    const prompt = isPlainObject(data.prompt) ? data.prompt : null\n    const format = prompt && (prompt.format === 'text' || prompt.format === 'messages')\n      ? (prompt.format as 'text' | 'messages')\n      : null","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/composables/app/useAppPromptGardenImport.ts#L512-L548","documentation":"Thrown by parseV1 in useAppPromptGardenImport.ts when validating a fetched Prompt Garden response. The parser expects a JSON object whose top-level `schema` field equals the exact string 'prompt-garden.prompt.v1'. Any other value (including a missing field, a typo, or a v2 schema identifier) is rejected because the importer only understands the v1 wire format.","triggerScenarios":"The fetched Garden URL returns JSON whose `schema` key is absent, null, a different string (e.g. 'prompt-garden.prompt.v2'), or the response body is from a different API endpoint entirely (error payload, HTML-in-JSON wrapper) that lacks the schema field.","commonSituations":"Prompt Garden backend upgraded to a newer schema version than the UI importer supports; pointing gardenBaseUrl at the wrong environment (staging vs prod); the URL resolved to an error/redirect page; hand-crafted JSON test fixtures that omit the schema marker.","solutions":["Inspect the raw fetched JSON (log the text before parsing) and confirm the top-level `schema` field is exactly 'prompt-garden.prompt.v1'","Verify gardenBaseUrl points at the correct environment/endpoint that serves v1 Garden prompts","If the backend now emits a newer schema, update parseV1 to accept it or pin the backend/export to v1","If the response is an error payload, fix the underlying fetch failure (auth, 404) before schema parsing matters"],"exampleFix":"// before\n{\n  \"schema\": \"prompt-garden.prompt\",\n  \"schemaVersion\": 1\n}\n\n// after\n{\n  \"schema\": \"prompt-garden.prompt.v1\",\n  \"schemaVersion\": 1\n}","handlingStrategy":"validation","validationCode":"const raw = JSON.parse(text)\nif (raw?.schema !== 'prompt-garden.prompt.v1') {\n  throw new TypeError(`Unexpected schema: ${String(raw?.schema)}`)\n}","typeGuard":"const isGardenV1Envelope = (d: unknown): d is { schema: string; schemaVersion: number } =>\n  isPlainObject(d) && d.schema === 'prompt-garden.prompt.v1' && d.schemaVersion === 1","tryCatchPattern":"catch (e) { if (e instanceof Error && e.message === 'Unsupported Garden response schema') { /* show 'incompatible export' UI */ } throw e }","preventionTips":["Pin the Garden exporter version to v1","Validate payloads against a JSON schema in CI fixtures","Log raw response text on import failure for diagnosis"],"tags":["prompt-garden","schema-validation","import","json"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}