linshenkx/prompt-optimizer · error · Error
Unsupported Garden response schemaVersion
Error message
Unsupported Garden response schemaVersion
What it means
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.
Source
Thrown at packages/ui/src/composables/app/useAppPromptGardenImport.ts:533
headers: {
Accept: 'application/json'
}
})
if (!resp.ok) {
throw new Error(`Garden request failed: ${resp.status}`)
}
const text = await resp.text()
const parseV1 = (data: unknown): FetchedPrompt => {
if (!isPlainObject(data)) {
throw new Error('Garden response must be a JSON object')
}
if (data.schema !== 'prompt-garden.prompt.v1') {
throw new Error('Unsupported Garden response schema')
}
if (data.schemaVersion !== 1) {
throw new Error('Unsupported Garden response schemaVersion')
}
const optimizerTarget = isPlainObject(data.optimizerTarget) ? data.optimizerTarget : null
const optimizerTargetKey =
optimizerTarget && typeof optimizerTarget.subModeKey === 'string'
? optimizerTarget.subModeKey.trim()
: ''
if (!optimizerTargetKey) {
throw new Error('Missing optimizerTarget.subModeKey')
}
const prompt = isPlainObject(data.prompt) ? data.prompt : null
const format = prompt && (prompt.format === 'text' || prompt.format === 'messages')
? (prompt.format as 'text' | 'messages')
: null
if (!format) {
throw new Error('Missing prompt.format')
}View on GitHub (pinned to 3e677b1d9f)
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
Example fix
// before
{ "schema": "prompt-garden.prompt.v1", "schemaVersion": "1" }
// after
{ "schema": "prompt-garden.prompt.v1", "schemaVersion": 1 } Defensive patterns
Strategy: validation
Validate before calling
if (raw?.schema === 'prompt-garden.prompt.v1' && raw.schemaVersion !== 1) {
console.warn(`Unsupported schemaVersion ${raw.schemaVersion}; expected 1`)
} Type guard
const isV1 = (d: unknown): boolean => isPlainObject(d) && d.schema === 'prompt-garden.prompt.v1' && d.schemaVersion === 1
Try / catch
catch (e) { if (/schemaVersion/.test(e.message)) notifyUser('This export uses a newer Garden format'); throw e } Prevention
- Keep exporter and importer versions in lockstep
- Use numeric (not string) schemaVersion when generating payloads
- Add contract tests for the v1 envelope
When it happens
Trigger: Response contains schemaVersion: 2, "1" (string instead of number), or the field is missing (undefined !== 1). Note strict equality: the string "1" is rejected.
Common situations: 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.
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
- Unsupported Garden response schema
- variables[${index}] is missing a valid "position" object.
- variables[${index}].position is missing a valid "originalTex
- variables[${index}].position is missing a valid "occurrence"
- variables[${index}] is missing a valid "reason" field.
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/b6c49884bc2a6c64.
Report an issue: GitHub.