mastra-ai/mastra · error · HTTPException
Version with id ${to} not found
Error message
Version with id ${to} not found What it means
The compare handler resolves the 'to' version via mcpClientStore.getVersion(to); when absent it throws HTTPException 404. The 'from' version was found but the 'to' target does not exist.
Source
Thrown at packages/server/src/server/handlers/mcp-client-versions.ts:475
if (!mcpClientStore) {
throw new HTTPException(500, { message: 'MCP clients storage domain is not available' });
}
const mcpClient = await mcpClientStore.getById(mcpClientId);
assertStoredResourceScope(mcpClient, await getStoredResourceScope(mastra, requestContext));
const fromVersion = await mcpClientStore.getVersion(from);
if (!fromVersion) {
throw new HTTPException(404, { message: `Version with id ${from} not found` });
}
if (fromVersion.mcpClientId !== mcpClientId) {
throw new HTTPException(404, {
message: `Version with id ${from} not found for MCP client ${mcpClientId}`,
});
}
const toVersion = await mcpClientStore.getVersion(to);
if (!toVersion) {
throw new HTTPException(404, { message: `Version with id ${to} not found` });
}
if (toVersion.mcpClientId !== mcpClientId) {
throw new HTTPException(404, {
message: `Version with id ${to} not found for MCP client ${mcpClientId}`,
});
}
const fromConfig = extractConfigFromVersion(
fromVersion as unknown as Record<string, unknown>,
MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,
);
const toConfig = extractConfigFromVersion(
toVersion as unknown as Record<string, unknown>,
MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,
);
const diffs = computeVersionDiffs(fromConfig, toConfig);
View on GitHub (pinned to 75dd419e61)
Solutions
- Pick a to id from the client's actual version list endpoint.
- Swap from/to if you intended to compare in the other direction using an existing id.
- Verify ids were not truncated/transformed by URL encoding.
Defensive patterns
Strategy: validation
Validate before calling
const { versions } = await (await fetch(`/api/stored/mcp-clients/${clientId}/versions`)).json();
if (!versions.some(v => v.id === toId)) throw new Error(`to version ${toId} not found`); Try / catch
try { await compare(from, to); } catch (e) { if (e.status === 404 && new RegExp(toId).test(e.message)) { /* pick a valid to id */ } else throw e; } Prevention
- Validate both from and to against the current version list
- Guard against comparing to versions newer than the latest created
- Encode ids correctly in query strings
When it happens
Trigger: GET /stored/mcp-clients/:mcpClientId/versions/compare?from=<id>&to=<id> where the to id is missing from storage.
Common situations: Comparing to a future/newer version id that hasn't been created yet; typo in the to param; stale UI pointing at a since-deleted version.
Related errors
- Version with id ${from} not found
- DATASET_ITEM_NOT_FOUND
- Version with id ${input.id} already exists
- Version number ${input.versionNumber} already exists for age
- Version with id ${input.id} already exists
AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30).
Data as JSON: /api/errors/d6a129c39267b002.
Report an issue: GitHub.