{"record":{"id":"059eacf7ca8b4334","repo":"JuliusBrussee/caveman","slug":"cannot-read-pending-agent-agent-native-bundle-j","errorCode":null,"errorMessage":"cannot read pending ${agent} agent-native bundle journal: ${(error as Error).message}","messagePattern":"cannot read pending (.+?) agent-native bundle journal: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":2594,"sourceCode":"      throw new Error(\"unsupported bundle journal\");\n    }\n    return value;\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n    throw new Error(`cannot read ${agent} agent-native bundle journal: ${(error as Error).message}`);\n  }\n}\n\nfunction readPendingAgentNativeBundleJournal(agent: \"claude\" | \"codex\"): AgentNativeBundleJournal | null {\n  try {\n    const value = JSON.parse(readFileSync(agentNativeBundleJournalPath(agent, true), \"utf8\")) as AgentNativeBundleJournal;\n    if (value.schema_version !== 1 || value.agent !== agent || !value.cloud_mcp || !Array.isArray(value.skills)) {\n      throw new Error(\"unsupported pending bundle journal\");\n    }\n    return value;\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n    throw new Error(`cannot read pending ${agent} agent-native bundle journal: ${(error as Error).message}`);\n  }\n}\n\nfunction readPendingAgentNativeBundleRemoval(agent: \"claude\" | \"codex\"): AgentNativeBundleJournal | null {\n  try {\n    const value = JSON.parse(readFileSync(agentNativeBundleRemovalJournalPath(agent), \"utf8\")) as AgentNativeBundleJournal;\n    if (value.schema_version !== 1 || value.agent !== agent || !value.cloud_mcp || !Array.isArray(value.skills)) {\n      throw new Error(\"unsupported pending bundle removal journal\");\n    }\n    return value;\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return null;\n    throw new Error(`cannot read pending ${agent} agent-native removal journal: ${(error as Error).message}`);\n  }\n}\n\ntype McpServerMarker = { command: string; args: string[]; config_path?: string; schema_version?: 1 };\n","sourceCodeStart":2576,"sourceCodeEnd":2612,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L2576-L2612","documentation":"Same family as the bundle journal read error but for the *pending* bundle journal — the staged record of an agent-native bundle install not yet committed. Any read/parse/validation failure other than ENOENT is wrapped and thrown; a missing file is treated as 'no pending journal' (null).","triggerScenarios":"readPendingAgentNativeBundleJournal(agent) hits EACCES/EISDIR on the pending journal path, invalid JSON, or schema mismatch (schema_version !== 1, wrong agent, missing cloud_mcp/skills).","commonSituations":"Interrupted install left a partially written pending journal; permissions changed; schema drift between CLI versions.","solutions":["Remove the corrupt pending journal file; the CLI then treats it as no pending state.","Fix permissions on the journal file/directory.","Validate the JSON matches schema_version 1 with cloud_mcp and skills fields.","Re-run the install command to rebuild pending state cleanly."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"try { JSON.parse(readFileSync(pendingJournalPath(agent), 'utf8')); } catch { console.warn('pending journal corrupt — safe to delete'); }","typeGuard":"function isPendingJournal(v: unknown): v is AgentNativeBundleJournal {\n  return typeof v === 'object' && v !== null && (v as any).schema_version === 1 &&\n    !!((v as any).cloud_mcp) && Array.isArray((v as any).skills);\n}","tryCatchPattern":"try { runUninstall() } catch (e) { if (String(e.message).includes('cannot read pending')) { fs.rmSync(pendingJournalPath, { force: true }); retry(); } }","preventionTips":["Let interrupted installs finish or clean up before starting a new one.","Treat pending journals as CLI-internal state; never edit by hand.","Back up and regenerate config after UID/permission changes."],"tags":["json","journal","pending-state","file-read"],"backgroundTag":"json-parse-error","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}