linshenkx/prompt-optimizer · error · Error
Unsupported Garden response schema
Error message
Unsupported Garden response schema
What it means
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.
Source
Thrown at packages/ui/src/composables/app/useAppPromptGardenImport.ts:530
const resp = await fetch(url, {
method: 'GET',
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')
: nullView on GitHub (pinned to 3e677b1d9f)
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
Example fix
// before
{
"schema": "prompt-garden.prompt",
"schemaVersion": 1
}
// after
{
"schema": "prompt-garden.prompt.v1",
"schemaVersion": 1
} Defensive patterns
Strategy: validation
Validate before calling
const raw = JSON.parse(text)
if (raw?.schema !== 'prompt-garden.prompt.v1') {
throw new TypeError(`Unexpected schema: ${String(raw?.schema)}`)
} Type guard
const isGardenV1Envelope = (d: unknown): d is { schema: string; schemaVersion: number } =>
isPlainObject(d) && d.schema === 'prompt-garden.prompt.v1' && d.schemaVersion === 1 Try / catch
catch (e) { if (e instanceof Error && e.message === 'Unsupported Garden response schema') { /* show 'incompatible export' UI */ } throw e } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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
- Invalid favorite share payload
- Invalid import data format
- variables[${index}] is missing a valid "position" object.
- variables[${index}].position is missing a valid "originalTex
- variables[${index}] is missing a valid "reason" field.
AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27).
Data as JSON: /api/errors/553e826b4499ec80.
Report an issue: GitHub.