{"record":{"id":"6064cf28368dc4ff","repo":"thedotmack/claude-mem","slug":"adapter-rejected-input-invalid-cwd-windsurf","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/windsurf.ts","lineNumber":12,"sourceCode":"import type { PlatformAdapter, NormalizedHookInput, HookResult } from '../types.js';\nimport { AdapterRejectedInput, isValidCwd } from './errors.js';\n\nexport const windsurfAdapter: PlatformAdapter = {\n  normalizeInput(raw) {\n    const r = (raw ?? {}) as any;\n    const toolInfo = r.tool_info ?? {};\n    const actionName: string = r.agent_action_name ?? '';\n\n    const cwd = toolInfo.cwd || process.cwd();\n    if (!isValidCwd(cwd)) {\n      throw new AdapterRejectedInput('invalid_cwd');\n    }\n\n    const base: NormalizedHookInput = {\n      sessionId: r.trajectory_id ?? r.execution_id,\n      cwd,\n      platform: 'windsurf',\n    };\n\n    switch (actionName) {\n      case 'pre_user_prompt':\n        return {\n          ...base,\n          prompt: toolInfo.user_prompt,\n        };\n\n      case 'post_write_code':\n        return {\n          ...base,","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/cli/adapters/windsurf.ts#L1-L30","documentation":"windsurfAdapter.normalizeInput throws AdapterRejectedInput('invalid_cwd') when the cwd taken from toolInfo.cwd or the process.cwd() fallback is not a non-empty string. Windsurf nests the working directory inside tool_info, so failure means tool_info.cwd was empty/invalid and no fallback applied.","triggerScenarios":"Windsurf hook payload with tool_info missing, tool_info: {}, or tool_info.cwd set to '' / a non-string while process.cwd() is also unusable; an explicitly invalid toolInfo.cwd value that fails the guard.","commonSituations":"Windsurf plugin updates dropping tool_info from the payload; running the hook from a deleted directory; hand-written automation sending partial payloads without tool_info.","solutions":["Ensure the Windsurf payload includes tool_info.cwd as a valid directory string","Omit toolInfo.cwd so the process.cwd() fallback applies (only works if toolInfo itself is fine and fallback needed)","Check Windsurf/plugin version for schema changes to tool_info","Catch AdapterRejectedInput with .reason === 'invalid_cwd' and inject a default cwd before re-invoking"],"exampleFix":"// before\nwindsurfAdapter.normalizeInput({ tool_info: { cwd: '' }, agent_action_name: 'edit' });\n// after\nwindsurfAdapter.normalizeInput({ tool_info: { cwd: '/absolute/path/to/workspace' }, agent_action_name: 'edit' });","handlingStrategy":"validation","validationCode":"const tc = raw?.tool_info?.cwd;\nif (tc !== undefined && (typeof tc !== 'string' || tc.length === 0)) throw new Error('tool_info.cwd must be a non-empty string');","typeGuard":"function hasValidToolCwd(t: unknown): t is { cwd: string } { return typeof (t as any)?.cwd === 'string' && (t as any).cwd.length > 0; }","tryCatchPattern":"try { adapter.normalizeInput(raw); } catch (e) { if (e instanceof AdapterRejectedInput && e.reason === 'invalid_cwd') { /* inject default cwd into tool_info and retry */ } else throw e; }","preventionTips":["Confirm Windsurf payloads include tool_info.cwd","Pin/verify Windsurf plugin versions to avoid schema drift","Set a default cwd in tool_info for automation scripts"],"tags":["input-validation","adapter","cwd","windsurf"],"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"}