{"record":{"id":"8a7db126fd259dd9","repo":"mastra-ai/mastra","slug":"claudesdkagent-resumedata-sessionid-must-be-a-stri","errorCode":null,"errorMessage":"ClaudeSDKAgent resumeData.sessionId must be a string.","messagePattern":"ClaudeSDKAgent resumeData\\.sessionId must be a string\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent-sdks/claude/src/index.ts","lineNumber":251,"sourceCode":"    return this.stream(data.message, createClaudeResumeRunOptions(data, options));\n  }\n}\n\nfunction validateClaudeResumeData(resumeData: ClaudeSDKAgentResumeData): ClaudeSDKAgentResumeData {\n  if (!isRecord(resumeData) || !('message' in resumeData)) {\n    throw new Error('ClaudeSDKAgent resumeData must include a message.');\n  }\n\n  const hasSessionId = 'sessionId' in resumeData;\n  const hasContinue = 'continue' in resumeData;\n\n  if (hasSessionId && hasContinue) {\n    throw new Error('ClaudeSDKAgent resumeData must include either sessionId or continue: true, not both.');\n  }\n\n  if (hasSessionId) {\n    if (typeof resumeData.sessionId !== 'string') {\n      throw new Error('ClaudeSDKAgent resumeData.sessionId must be a string.');\n    }\n    return resumeData;\n  }\n\n  if (hasContinue) {\n    if (resumeData.continue !== true) {\n      throw new Error('ClaudeSDKAgent resumeData.continue must be true when provided.');\n    }\n    return resumeData;\n  }\n\n  throw new Error('ClaudeSDKAgent resumeData must include sessionId or continue: true.');\n}\n\nfunction createClaudeResumeRunOptions<OUTPUT>(\n  resumeData: ClaudeSDKAgentResumeData,\n  options?: ClaudeSDKAgentRunOptions<OUTPUT>,\n): ClaudeSDKAgentRunOptions<OUTPUT> {","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/claude/src/index.ts#L233-L269","documentation":"The restore handler fetches the version to restore with getVersion(versionId); when it returns null the endpoint returns 404 with this message. Nothing can be restored because the version record is absent.","triggerScenarios":"POST restore where :versionId doesn't exist in the agents store for any agent.","commonSituations":"Version data purged by cleanup jobs; restoring from a fresh database that never recorded that version; copying versionIds between environments.","solutions":["Fetch GET /api/agents/:agentId/versions and pick an existing versionId","Fix the versionId path parameter","Connect to the storage environment that contains the version history","Re-snapshot the agent configuration to create a new version to restore"],"exampleFix":"// before\nrestore(versionId); // invented id\n// after\nconst versions = await fetch(`/api/agents/${agentId}/versions`).then(r => r.json());\nif (versions.length) restore(versions[0].id);","handlingStrategy":"validation","validationCode":"const versions = await fetch(`/api/agents/${agentId}/versions`).then(r => r.json());\nif (!versions.some(v => v.id === versionId)) throw new Error(`Cannot restore: version ${versionId} missing`);","typeGuard":"function restorable(versions: {id: string}[], versionId: string): boolean {\n  return versions.some(v => v.id === versionId);\n}","tryCatchPattern":"try {\n  await fetch(`/api/agents/${agentId}/versions/${versionId}/restore`, { method: 'POST' });\n} catch (e) {\n  if (isHttpError(e) && e.status === 404 && /Version with id .* not found$/.test(e.message)) {\n    // list versions and choose a valid one\n  } else throw e;\n}","preventionTips":["Refresh the version list before restore instead of caching versionIds","Back up version tables if retention pruning is enabled","Create a fresh snapshot if no versions exist","Validate versionId format before calling"],"tags":["http-404","not-found","versions","rest-api"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}