{"record":{"id":"03a0bd5dc731326a","repo":"mastra-ai/mastra","slug":"version-with-id-from-not-found","errorCode":null,"errorMessage":"Version with id ${from} not found","messagePattern":"Version with id (.+?) not found","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/agent-versions.ts","lineNumber":534,"sourceCode":"  handler: async ({ mastra, agentId, from, to, requestContext }) => {\n    try {\n      const storage = mastra.getStorage();\n\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      );","sourceCodeStart":516,"sourceCodeEnd":552,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/agent-versions.ts#L516-L552","documentation":"The diff handler resolves the 'from' version before the 'to' version. If agentsStore.getVersion(from) returns null, the source version of the comparison doesn't exist and the endpoint returns a 404 naming the from id.","triggerScenarios":"Calling the version diff endpoint with a from versionId that was never created, was already deleted (possibly by the retention limit), or belongs to another database/environment.","commonSituations":"Comparing against a version pruned by enforceRetentionLimit; stale ids in a UI dropdown after a DB switch; diffing across environments where version ids aren't shared.","solutions":["List current versions (GET /api/agents/{agentId}/versions) and pick a valid from id","Lower the retention limit or stop pruning if older versions must remain diffable","Confirm the request hits the intended storage backend/environment","Check for typos or swapped from/to parameters"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const versions = await (await fetch(`/api/agents/${agentId}/versions`)).json();\nif (!versions.some((v: { id: string }) => v.id === from)) {\n  throw new Error(`'from' version ${from} does not exist for agent ${agentId}`);\n}\nif (!versions.some((v: { id: string }) => v.id === to)) {\n  throw new Error(`'to' version ${to} does not exist for agent ${agentId}`);\n}","typeGuard":"function diffable(versions: { id: string }[], from: string, to: string): boolean {\n  return versions.some(v => v.id === from) && versions.some(v => v.id === to);\n}","tryCatchPattern":"try {\n  const res = await fetch(`/api/agents/${agentId}/versions/diff?from=${from}&to=${to}`);\n  if (res.status === 404 && (await res.json()).message.includes(`Version with id ${from} not found`)) {\n    // refresh version list; the 'from' version may have been pruned\n  }\n} catch (err) { /* network */ }","preventionTips":["Validate both from/to ids against the versions list before diffing","Raise the retention limit if old versions must remain diffable","Diff only versions listed by the current environment","Double-check from/to parameter order in client code"],"tags":["http-404","not-found","server","rest"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}