mastra-ai/mastra · error · HTTPException
Failed to retrieve created version
Error message
Failed to retrieve created version
What it means
Thrown as HTTP 500 when createVersion on the scorer store returned (or resolved without) a usable versionId, and the follow-up getVersion(versionId) could not fetch the row that was supposedly created. This indicates the write did not land or the returned id is invalid — an internal consistency failure rather than user error.
Source
Thrown at packages/server/src/server/handlers/scorer-versions.ts:157
}
const previousConfig = latestVersion
? extractConfigFromVersion(latestVersion as unknown as Record<string, unknown>, SNAPSHOT_CONFIG_FIELDS)
: null;
const changedFields = calculateChangedFields(previousConfig, currentConfig);
const { versionId } = await createVersionWithRetry(
scorerStore as unknown as VersionedStoreInterface,
scorerId,
'scorerDefinitionId',
currentConfig,
changedFields,
{ changeMessage },
);
const version = await scorerStore.getVersion(versionId);
if (!version) {
throw new HTTPException(500, { message: 'Failed to retrieve created version' });
}
await enforceRetentionLimit(
scorerStore as unknown as VersionedStoreInterface,
scorerId,
'scorerDefinitionId',
scorer.activeVersionId,
);
return version;
} catch (error) {
return handleError(error, 'Error creating scorer version');
}
},
});
/**
* GET /stored/scorers/:scorerId/versions/:versionId - Get a specific versionView on GitHub (pinned to 75dd419e61)
Solutions
- Retry the version creation request once to rule out transient consistency issues
- Check server logs/storage adapter logs for a failed transaction or underlying DB error
- Verify the backing database is healthy (connections, replication lag)
- If using a custom versioned store, ensure createVersion commits before returning and the id matches a readable row
Example fix
// before (custom store: returns id before commit) const id = crypto.randomUUID(); queueInsert(row); return id; // after const id = crypto.randomUUID(); await this.db.insert(rows).values(row); return id;
Defensive patterns
Strategy: retry
Try / catch
async function createVersionWithRetry(scorerId: string, msg?: string, attempts = 2) {
for (let i = 0; i < attempts; i++) {
const res = await fetch(`/api/scorers/${scorerId}/versions`, { method: 'POST', body: JSON.stringify({ changeMessage: msg }) });
if (res.ok) return res.json();
const body = await res.json();
if (res.status === 500 && body.message === 'Failed to retrieve created version' && i < attempts - 1) continue;
throw body;
}
} Prevention
- Use a database with strong read-after-write consistency for the versions table
- Alert on this 500 — it usually indicates a store/DB bug, not user error
- Keep custom versioned stores committing before returning ids
- Watch replication lag if reading versions from a replica
When it happens
Trigger: POST /api/scorers/{scorerId}/versions where the store's createVersion succeeds nominally but the subsequent getVersion(versionId) returns undefined — e.g. a store bug, a failed transaction that still returned an id, or replication lag/consistency issues in the backing database.
Common situations: Distributed databases with read-after-write inconsistency; concurrent deletes racing the create; buggy custom versioned store implementations; partial migration leaving the versions table unusable.
Related errors
- AcpAgent does not support resuming suspended generate calls
- AcpAgent does not support resuming suspended stream calls
- ACP prompt stopped before completing: ${response.stopReason}
- ClaudeSDKAgent resumeData must include a message.
- Repository link ${session.projectRepositoryId} is incomplete
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/380daf2325923390.
Report an issue: GitHub.