{"record":{"id":"fa16d1347868d5bf","repo":"mastra-ai/mastra","slug":"version-with-id-from-not-found-for-agent-agen","errorCode":null,"errorMessage":"Version with id ${from} not found for agent ${agentId}","messagePattern":"Version with id (.+?) not found for agent (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/agent-versions.ts","lineNumber":537,"sourceCode":"\n      if (!storage) {\n        throw new HTTPException(500, { message: 'Storage is not configured' });\n      }\n\n      const agentsStore = await storage.getStore('agents');\n      if (!agentsStore) {\n        throw new HTTPException(500, { message: 'Agents storage domain is not available' });\n      }\n      const agent = await agentsStore.getById(agentId);\n      assertStoredResourceScope(agent, await getStoredResourceScope(mastra, requestContext));\n\n      // Get both versions\n      const fromVersion = await agentsStore.getVersion(from);\n      if (!fromVersion) {\n        throw new HTTPException(404, { message: `Version with id ${from} not found` });\n      }\n      if (fromVersion.agentId !== agentId) {\n        throw new HTTPException(404, { message: `Version with id ${from} not found for agent ${agentId}` });\n      }\n\n      const toVersion = await agentsStore.getVersion(to);\n      if (!toVersion) {\n        throw new HTTPException(404, { message: `Version with id ${to} not found` });\n      }\n      if (toVersion.agentId !== agentId) {\n        throw new HTTPException(404, { message: `Version with id ${to} not found for agent ${agentId}` });\n      }\n\n      // Extract config fields from both versions (top-level, no .snapshot)\n      const fromConfig = extractConfigFromVersion(\n        fromVersion as unknown as Record<string, unknown>,\n        SNAPSHOT_CONFIG_FIELDS,\n      );\n      const toConfig = extractConfigFromVersion(\n        toVersion as unknown as Record<string, unknown>,\n        SNAPSHOT_CONFIG_FIELDS,","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/agent-versions.ts#L519-L555","documentation":"Thrown by the GET /stored/agents/:agentId/versions/compare handler when the `from` version id exists in storage but is owned by a different agent than the :agentId path parameter. The server deliberately returns a 404 (rather than 403) so it does not leak the existence of another agent's versions.","triggerScenarios":"Calling compare-versions with a `from` version id that belongs to agent A while the route targets agent B, e.g. GET /stored/agents/agent-b/versions/compare?from=<agent-a-version-id>&to=<agent-b-version-id>. Also happens after copying a version id from another agent's version list, or when the agentId path param is stale after the agent was re-created under a different id.","commonSituations":"Multi-agent dashboards where version ids from one agent's table are passed into another agent's compare endpoint; cached version ids in a frontend after an agent was deleted and recreated; mixing up similarly-named agents in scripts or tests.","solutions":["Verify the `from` version id belongs to the same agent as the :agentId path parameter (list versions via GET /stored/agents/:agentId/versions first)","Correct the agentId path parameter if you actually meant the other agent","Clear stale cached version ids in the client and refetch the version list for the target agent"],"exampleFix":"// before\nGET /stored/agents/agent-b/versions/compare?from=ver-of-agent-a&to=ver-of-agent-b\n// after\nGET /stored/agents/agent-a/versions/compare?from=ver-of-agent-a&to=ver-of-agent-a-other","handlingStrategy":"validation","validationCode":"const versions = await fetch(`/api/stored/agents/${agentId}/versions`).then(r => r.json());\nif (!versions.some(v => v.id === fromId)) {\n  throw new Error(`Version ${fromId} does not belong to agent ${agentId}`);\n}","typeGuard":"function belongsToAgent(version: { agentId: string } | null, agentId: string): version is { agentId: string } {\n  return version !== null && version.agentId === agentId;\n}","tryCatchPattern":"try {\n  const res = await compareVersions(agentId, fromId, toId);\n} catch (e) {\n  if (isHttpException(e, 404)) {\n    // refetch version list for this agent and prompt user to reselect\n  }\n}","preventionTips":["Always source version ids from the same agent's version-list endpoint","Never hardcode or share version ids across agents in tests or scripts","Invalidate cached version selections when the target agent changes in the UI"],"tags":["http-404","agent-versions","rest-api","ownership"],"backgroundTag":"version-not-found-for-agent","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}