thedotmack/claude-mem · error · AdapterRejectedInput
adapter rejected input: invalid_cwd
Error message
adapter rejected input: invalid_cwd
What it means
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'.
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
Example fix
// before
rawAdapter.normalizeInput({ cwd: '' });
// after
rawAdapter.normalizeInput({ cwd: process.cwd() }); Defensive patterns
Strategy: validation
Validate before calling
if (!raw || typeof raw.cwd !== 'string' || raw.cwd.length === 0) raw = { ...(raw ?? {}), cwd: process.cwd() }; Type guard
function hasValidCwd(v: unknown): v is string { return typeof v === 'string' && v.length > 0; } Try / catch
try { adapter.normalizeInput(raw); } catch (e) { if (e instanceof AdapterRejectedInput && e.reason === 'invalid_cwd') { /* normalize payload and retry */ } else throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
- adapter rejected input: invalid_cwd
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/80787c9ce0d417ff.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/adapters/raw.ts:9
import type { PlatformAdapter, NormalizedHookInput, HookResult } from '../types.js';
import { AdapterRejectedInput, isValidCwd } from './errors.js';
export const rawAdapter: PlatformAdapter = {
normalizeInput(raw) {
const r = (raw ?? {}) as any;
const cwd = r.cwd || process.cwd();
if (!isValidCwd(cwd)) {
throw new AdapterRejectedInput('invalid_cwd');
}
return {
sessionId: r.sessionId ?? r.session_id ?? 'unknown',
cwd,
prompt: r.prompt,
toolName: r.toolName ?? r.tool_name,
toolInput: r.toolInput ?? r.tool_input,
toolResponse: r.toolResponse ?? r.tool_response,
toolUseId: r.toolUseId ?? r.tool_use_id,
transcriptPath: r.transcriptPath ?? r.transcript_path,
filePath: r.filePath ?? r.file_path,
edits: r.edits,
};
},
formatOutput(result) {
return result;
}
};View on GitHub (pinned to d8bc9755e7)