{"record":{"id":"c237b97aa97c5dda","repo":"mastra-ai/mastra","slug":"claudesdkagent-resumedata-continue-must-be-true-wh","errorCode":null,"errorMessage":"ClaudeSDKAgent resumeData.continue must be true when provided.","messagePattern":"ClaudeSDKAgent resumeData\\.continue must be true when provided\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"agent-sdks/claude/src/index.ts","lineNumber":258,"sourceCode":"  }\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> {\n  const sdkOptions: ClaudeSDKOptions = { ...options?.sdkOptions };\n\n  if ('sessionId' in resumeData && typeof resumeData.sessionId === 'string') {\n    sdkOptions.resume = resumeData.sessionId;\n    if (resumeData.forkSession !== undefined) {\n      sdkOptions.forkSession = resumeData.forkSession;\n    }","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/agent-sdks/claude/src/index.ts#L240-L276","documentation":"The version record exists but belongs to a different agent than :agentId; the restore handler returns 404 with this message (same masking rationale as the get handler) to avoid disclosing versions across agents.","triggerScenarios":"POST restore on /api/agents/:agentId/versions/:versionId where version.agentId !== agentId.","commonSituations":"Client mixing selection state across agents; reusing a versionId after the agent was duplicated/recreated under a new id; programmatic scripts iterating mismatched id pairs.","solutions":["Ensure versionId comes from the same agent's version list as agentId","Correct :agentId to the agent the version belongs to","Clear/refresh stale client state before retrying","Validate pairing client-side (version.agentId === agentId) before calling the endpoint"],"exampleFix":"// before\nawait fetch(`/api/agents/${agentA.id}/versions/${versionOfB.id}/restore`, { method: 'POST' });\n// after\nif (versionOfB.agentId === agentA.id) {\n  await fetch(`/api/agents/${agentA.id}/versions/${versionOfB.id}/restore`, { method: 'POST' });\n}","handlingStrategy":"validation","validationCode":"const versions = await fetch(`/api/agents/${agentId}/versions`).then(r => r.json());\nif (!versions.some(v => v.id === versionId)) {\n  throw new Error(`Version ${versionId} does not belong to agent ${agentId}`);\n}","typeGuard":"function isOwnedVersion(v: {id: string; agentId: string} | undefined, agentId: string): v is {id: string; agentId: string} {\n  return !!v && v.agentId === agentId;\n}","tryCatchPattern":"try {\n  await fetch(`/api/agents/${agentId}/versions/${versionId}/restore`, { method: 'POST' });\n} catch (e) {\n  if (isHttpError(e) && e.status === 404 && e.message.includes('not found for agent')) {\n    // correct the agentId/versionId pairing before retrying\n  } else throw e;\n}","preventionTips":["Always restore using (agentId, versionId) pairs fetched together","Re-sync client selection state after duplicating/recreating agents","Add integration tests that assert ownership before restore","Never reuse versionIds across agents in scripts or migrations"],"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"}