{"record":{"id":"d4469206322f8614","repo":"mastra-ai/mastra","slug":"failed-to-retrieve-created-version-d44692","errorCode":null,"errorMessage":"Failed to retrieve created version","messagePattern":"Failed to retrieve created version","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"packages/server/src/server/handlers/mcp-client-versions.ts","lineNumber":150,"sourceCode":"            latestVersion as unknown as Record<string, unknown>,\n            MCP_CLIENT_SNAPSHOT_CONFIG_FIELDS,\n          )\n        : null;\n\n      const changedFields = calculateChangedFields(previousConfig, currentConfig);\n\n      const { versionId } = await createVersionWithRetry(\n        mcpClientStore as unknown as VersionedStoreInterface,\n        mcpClientId,\n        'mcpClientId',\n        currentConfig,\n        changedFields,\n        { changeMessage },\n      );\n\n      const version = await mcpClientStore.getVersion(versionId);\n      if (!version) {\n        throw new HTTPException(500, { message: 'Failed to retrieve created version' });\n      }\n\n      await enforceRetentionLimit(\n        mcpClientStore as unknown as VersionedStoreInterface,\n        mcpClientId,\n        'mcpClientId',\n        mcpClient.activeVersionId,\n      );\n\n      return version;\n    } catch (error) {\n      return handleError(error, 'Error creating MCP client version');\n    }\n  },\n});\n\n/**\n * GET /stored/mcp-clients/:mcpClientId/versions/:versionId - Get a specific version","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/server/src/server/handlers/mcp-client-versions.ts#L132-L168","documentation":"This 500 is thrown when a version was just created via the store's create-version operation but the subsequent getVersion(versionId) call cannot retrieve it. It indicates an internal inconsistency between the store's write and read paths rather than a user error.","triggerScenarios":"Creating a new MCP client version via the endpoint; the create call returns a versionId, but mcpClientStore.getVersion(versionId) immediately afterwards returns null (store write not yet visible to reads, or a faulty storage adapter).","commonSituations":"Using a custom/storage adapter whose create-version does not commit synchronously; eventual-consistency lag in the backing database; a bug in a third-party storage driver.","solutions":["Retry the request; if transient replication lag caused it, the version will be readable","Verify the storage adapter's createVersion/getVersion implementation commits before returning","Check the storage backend logs for failed writes","Upgrade @mastra/core storage packages to the latest patch version"],"exampleFix":"null","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  const res = await fetch(`/api/mcp-clients/${id}/versions`, { method: 'POST', ... });\n  if (res.status === 500) {\n    // retry once after short delay; likely read-after-write lag\n    await new Promise(r => setTimeout(r, 500));\n    return retryOnce();\n  }\n  return await res.json();\n} catch (err) {\n  // log and fall back to listing versions to confirm creation\n}","preventionTips":["Use official, up-to-date storage adapters","Verify custom store implementations commit writes before returning","Monitor storage backend for replication lag"],"tags":["http-500","storage","internal-error","mcp"],"backgroundTag":"storage-write-read-inconsistency","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}