{"record":{"id":"babec875cad21395","repo":"mastra-ai/mastra","slug":"version-with-id-from-not-found-for-prompt-block","errorCode":null,"errorMessage":"Version with id ${from} not found for prompt block ${promptBlockId}","messagePattern":"Version with id (.+?) not found for prompt block (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"packages/server/src/server/handlers/prompt-block-versions.ts","lineNumber":463,"sourceCode":"      const storage = mastra.getStorage();\n\n      if (!storage) {\n        throw new HTTPException(500, { message: 'Storage is not configured' });\n      }\n\n      const promptBlockStore = await storage.getStore('promptBlocks');\n      if (!promptBlockStore) {\n        throw new HTTPException(500, { message: 'Prompt blocks storage domain is not available' });\n      }\n      const promptBlock = await promptBlockStore.getById(promptBlockId);\n      assertStoredResourceScope(promptBlock, await getStoredResourceScope(mastra, requestContext));\n\n      const fromVersion = await promptBlockStore.getVersion(from);\n      if (!fromVersion) {\n        throw new HTTPException(404, { message: `Version with id ${from} not found` });\n      }\n      if (fromVersion.blockId !== promptBlockId) {\n        throw new HTTPException(404, {\n          message: `Version with id ${from} not found for prompt block ${promptBlockId}`,\n        });\n      }\n\n      const toVersion = await promptBlockStore.getVersion(to);\n      if (!toVersion) {\n        throw new HTTPException(404, { message: `Version with id ${to} not found` });\n      }\n      if (toVersion.blockId !== promptBlockId) {\n        throw new HTTPException(404, {\n          message: `Version with id ${to} not found for prompt block ${promptBlockId}`,\n        });\n      }\n\n      const fromConfig = extractConfigFromVersion(\n        fromVersion as unknown as Record<string, unknown>,\n        SNAPSHOT_CONFIG_FIELDS,\n      );","sourceCodeStart":445,"sourceCodeEnd":481,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/prompt-block-versions.ts#L445-L481","documentation":"Thrown when the 'from' version exists but belongs to a different prompt block than the one addressed in the URL (fromVersion.blockId !== promptBlockId). Masked as 404 to avoid disclosing cross-block data. It is a parent/child id mismatch, not a missing record.","triggerScenarios":"Diff/revert request pairing prompt block A in the path with a 'from' version that belongs to prompt block B.","commonSituations":"Building diff UIs that keep version ids from previously selected blocks, copy/paste mistakes across blocks, or clients caching (blockId, versionId) pairs inconsistently.","solutions":["Look up 'from' only from the target block's own version list before calling the route.","Fix the promptBlockId path segment if the version's owner is the block you actually meant.","Reset client caches so version selections always reset when the selected block changes."],"exampleFix":"// before\nconst from = lastSelectedVersionId; // may belong to another block\n// after\nconst versions = await get(`/prompt-blocks/${blockId}/versions`);\nconst from = versions.find(v => v.id === wantedId)?.id ?? versions[0].id;","handlingStrategy":"type-guard","validationCode":"const versions = await getBlockVersions(promptBlockId);\nif (!versions.some(v => v.id === from)) {\n  throw new Error(`'from' version ${from} does not belong to block ${promptBlockId}`);\n}","typeGuard":"function ownsVersion(version: { id: string; blockId: string } | undefined, promptBlockId: string): version is { id: string; blockId: string } {\n  return !!version && version.blockId === promptBlockId;\n}","tryCatchPattern":"try {\n  await revertVersions(promptBlockId, from, to);\n} catch (e) {\n  if (e.status === 404 && e.message.includes('not found for prompt block')) {\n    // mismatch: rebind 'from' to a version of this block\n  }\n  throw e;\n}","preventionTips":["Derive both from/to from the same block's version list response.","Clear per-block selections when switching blocks in UIs.","Validate version.blockId client-side before issuing the call."],"tags":["http-404","rest-api","id-mismatch","versions"],"backgroundTag":"resource-not-found-404","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}