{"record":{"id":"80787c9ce0d417ff","repo":"thedotmack/claude-mem","slug":"adapter-rejected-input-invalid-cwd-raw","errorCode":null,"errorMessage":"adapter rejected input: invalid_cwd","messagePattern":"adapter rejected input: invalid_cwd","errorType":"validation","errorClass":"AdapterRejectedInput","httpStatus":null,"severity":"error","filePath":"src/cli/adapters/raw.ts","lineNumber":9,"sourceCode":"import type { PlatformAdapter, NormalizedHookInput, HookResult } from '../types.js';\nimport { AdapterRejectedInput, isValidCwd } from './errors.js';\n\nexport const rawAdapter: PlatformAdapter = {\n  normalizeInput(raw) {\n    const r = (raw ?? {}) as any;\n    const cwd = r.cwd || process.cwd();\n    if (!isValidCwd(cwd)) {\n      throw new AdapterRejectedInput('invalid_cwd');\n    }\n    return {\n      sessionId: r.sessionId ?? r.session_id ?? 'unknown',\n      cwd,\n      prompt: r.prompt,\n      toolName: r.toolName ?? r.tool_name,\n      toolInput: r.toolInput ?? r.tool_input,\n      toolResponse: r.toolResponse ?? r.tool_response,\n      toolUseId: r.toolUseId ?? r.tool_use_id,\n      transcriptPath: r.transcriptPath ?? r.transcript_path,\n      filePath: r.filePath ?? r.file_path,\n      edits: r.edits,\n    };\n  },\n  formatOutput(result) {\n    return result;\n  }\n};","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/cli/adapters/raw.ts#L1-L27","documentation":"rawAdapter.normalizeInput throws AdapterRejectedInput('invalid_cwd') when r.cwd (or the process.cwd() fallback) is not a non-empty string. This adapter is the escape hatch for arbitrary payloads, so the only hard requirement it enforces is a usable cwd plus defaults sessionId to 'unknown'.","triggerScenarios":"Calling the raw adapter with raw where cwd is '', null, a number, or another non-string, and process.cwd() fallback also unavailable; or running from a deleted working directory.","commonSituations":"Generic integrations forwarding third-party JSON where the cwd field has the wrong type; scripts run via exec from an unlinked directory; test fixtures with malformed cwd.","solutions":["Pass cwd as a valid absolute directory string in the raw payload","Omit cwd to use process.cwd()","Fix the upstream producer so it emits cwd as a string, not a number/object","Catch AdapterRejectedInput, check .reason === 'invalid_cwd', and sanitize the payload before retry"],"exampleFix":"// before\nrawAdapter.normalizeInput({ cwd: '' });\n// after\nrawAdapter.normalizeInput({ cwd: process.cwd() });","handlingStrategy":"validation","validationCode":"if (!raw || typeof raw.cwd !== 'string' || raw.cwd.length === 0) raw = { ...(raw ?? {}), cwd: process.cwd() };","typeGuard":"function hasValidCwd(v: unknown): v is string { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":"try { adapter.normalizeInput(raw); } catch (e) { if (e instanceof AdapterRejectedInput && e.reason === 'invalid_cwd') { /* normalize payload and retry */ } else throw e; }","preventionTips":["Validate third-party payload field types before forwarding to the raw adapter","Avoid invoking from deleted working directories","Default missing cwd to process.cwd() upstream"],"tags":["input-validation","adapter","cwd"],"backgroundTag":"invalid-argument-value","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}