{"record":{"id":"b6c49884bc2a6c64","repo":"linshenkx/prompt-optimizer","slug":"unsupported-garden-response-schemaversion","errorCode":null,"errorMessage":"Unsupported Garden response schemaVersion","messagePattern":"Unsupported Garden response schemaVersion","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/composables/app/useAppPromptGardenImport.ts","lineNumber":533,"sourceCode":"    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\n    if (!format) {\n      throw new Error('Missing prompt.format')\n    }","sourceCodeStart":515,"sourceCodeEnd":551,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/composables/app/useAppPromptGardenImport.ts#L515-L551","documentation":"Thrown when a Garden response has the correct `schema` string but its `schemaVersion` field is not the number 1. The importer pins to schemaVersion 1 so that future minor/major format changes fail fast instead of silently mis-parsing fields like optimizerTarget or prompt.","triggerScenarios":"Response contains schemaVersion: 2, \"1\" (string instead of number), or the field is missing (undefined !== 1). Note strict equality: the string \"1\" is rejected.","commonSituations":"Backend bumped schemaVersion while keeping the schema identifier; serialized responses where version was stringified (e.g. after being stored as text in a DB); fixtures written with a quoted version.","solutions":["Check the exact value and type of schemaVersion in the fetched payload; it must be the number 1","If the backend now sends 2, either update the importer to handle v2 or export from a v1-compatible source","Ensure no middleware/stringification converts numbers to strings in transit"],"exampleFix":"// before\n{ \"schema\": \"prompt-garden.prompt.v1\", \"schemaVersion\": \"1\" }\n\n// after\n{ \"schema\": \"prompt-garden.prompt.v1\", \"schemaVersion\": 1 }","handlingStrategy":"validation","validationCode":"if (raw?.schema === 'prompt-garden.prompt.v1' && raw.schemaVersion !== 1) {\n  console.warn(`Unsupported schemaVersion ${raw.schemaVersion}; expected 1`)\n}","typeGuard":"const isV1 = (d: unknown): boolean => isPlainObject(d) && d.schema === 'prompt-garden.prompt.v1' && d.schemaVersion === 1","tryCatchPattern":"catch (e) { if (/schemaVersion/.test(e.message)) notifyUser('This export uses a newer Garden format'); throw e }","preventionTips":["Keep exporter and importer versions in lockstep","Use numeric (not string) schemaVersion when generating payloads","Add contract tests for the v1 envelope"],"tags":["prompt-garden","schema-validation","version-mismatch"],"backgroundTag":"schema-validation-failed","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}