mastra-ai/mastra · error · HTTPException
Version with id ${to} not found
Error message
Version with id ${to} not found What it means
Thrown by the GET /stored/agents/:agentId/versions/compare handler when the `to` version id cannot be found in the agents storage store at all. It is a plain 404 indicating the requested version row does not exist.
Source
Thrown at packages/server/src/server/handlers/agent-versions.ts:542
const agentsStore = await storage.getStore('agents');
if (!agentsStore) {
throw new HTTPException(500, { message: 'Agents storage domain is not available' });
}
const agent = await agentsStore.getById(agentId);
assertStoredResourceScope(agent, await getStoredResourceScope(mastra, requestContext));
// Get both versions
const fromVersion = await agentsStore.getVersion(from);
if (!fromVersion) {
throw new HTTPException(404, { message: `Version with id ${from} not found` });
}
if (fromVersion.agentId !== agentId) {
throw new HTTPException(404, { message: `Version with id ${from} not found for agent ${agentId}` });
}
const toVersion = await agentsStore.getVersion(to);
if (!toVersion) {
throw new HTTPException(404, { message: `Version with id ${to} not found` });
}
if (toVersion.agentId !== agentId) {
throw new HTTPException(404, { message: `Version with id ${to} not found for agent ${agentId}` });
}
// Extract config fields from both versions (top-level, no .snapshot)
const fromConfig = extractConfigFromVersion(
fromVersion as unknown as Record<string, unknown>,
SNAPSHOT_CONFIG_FIELDS,
);
const toConfig = extractConfigFromVersion(
toVersion as unknown as Record<string, unknown>,
SNAPSHOT_CONFIG_FIELDS,
);
// Compute diffs on the config fields
const diffs = computeVersionDiffs(fromConfig, toConfig);
View on GitHub (pinned to 75dd419e61)
Solutions
- List the agent's versions via GET /stored/agents/:agentId/versions and use an existing version id for `to`
- Check the storage backend is the one you expect (connection/config) — the version may exist in a different database
- Recreate the deleted version or re-publish so a `to` target exists
Example fix
// before GET /stored/agents/agent-1/versions/compare?from=v1&to=00000000-0000-0000-0000-000000000000 // after GET /stored/agents/agent-1/versions/compare?from=v1&to=<id-from-GET-/stored/agents/agent-1/versions>
Defensive patterns
Strategy: validation
Validate before calling
const { versions } = await fetch(`/api/stored/agents/${agentId}/versions`).then(r => r.json());
if (!versions.some(v => v.id === toId)) {
throw new Error(`Version ${toId} not found for agent ${agentId}`);
} Try / catch
try {
const res = await compareVersions(agentId, fromId, toId);
} catch (e) {
if (isHttpException(e, 404) && String(e.message).includes(toId)) {
// `to` missing: refresh list, ask user to pick an existing version
}
} Prevention
- Fetch version ids dynamically rather than persisting them in config/code
- Confirm you are connected to the intended storage backend/environment
- Handle draft-version deletion (pruning/publishing) by refreshing selections
When it happens
Trigger: Calling GET /stored/agents/:agentId/versions/compare?from=<valid>&to=<nonexistent-or-deleted-version-id>. Happens when the `to` version was deleted (e.g. draft pruned, stored agent removed), the id is mistyped/truncated, or the id was never created.
Common situations: Typos or truncation of version UUIDs in scripts; comparing against a draft version that was overwritten or deleted; environment mismatch (pointing at a database where that version was never persisted); stale bookmarks/links after cleanup jobs.
Related errors
- Version with id ${from} not found for agent ${agentId}
- Version with id ${to} not found for agent ${agentId}
- Model "${modelId}" is not available. Available models: ${ids
- ACP connection is not initialized
- Model "${this.options.model}" is not available. Available mo
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/d08fb76af7cfaa93.
Report an issue: GitHub.