thedotmack/claude-mem · error
fileEditHandler requires filePath
Error message
fileEditHandler requires filePath
What it means
fileEditHandler.execute throws Error('fileEditHandler requires filePath') when the normalized hook input has no filePath. The handler's whole purpose is applying edits to a specific file, so a missing path is an invariant violation of the input contract.
Solutions
- Only route PostToolUse/Edit-type events to fileEditHandler; filter by hook_event_name/tool_name before dispatch
- Ensure the payload includes file_path and the adapter maps it to input.filePath
- When constructing NormalizedHookInput manually, set filePath to an absolute path
- Catch the error and return early/skip for events without a file
Example fix
// before
await fileEditHandler.execute({ sessionId, cwd }); // throws
// after
await fileEditHandler.execute({ sessionId, cwd, filePath: '/abs/path/file.ts', edits }); Defensive patterns
Strategy: validation
Validate before calling
if (!input.filePath) return { success: false, error: 'no filePath; not an edit event' };
await fileEditHandler.execute(input); Type guard
function isFileEditInput(i: NormalizedHookInput): i is NormalizedHookInput & { filePath: string } { return typeof i.filePath === 'string' && i.filePath.length > 0; } Try / catch
try { await fileEditHandler.execute(input); } catch (e) { if (e.message === 'fileEditHandler requires filePath') { /* skip or route to generic handler */ } else throw e; } Prevention
- Route only PostToolUse/Edit events to fileEditHandler
- Verify the adapter maps file_path from the payload to input.filePath
- When building inputs manually, always set filePath (absolute path)
- Check upstream tool schema for renamed fields (file_path vs path)
When it happens
Trigger: Invoking fileEditHandler with a NormalizedHookInput built from a payload lacking file_path (Claude Code hook schema uses tool_input.file_path; adapters map it to input.filePath) — e.g. non-edit events (session start, prompts) routed to this handler, or adapter normalization dropping the field because the key name didn't match.
Common situations: Hook configuration routing every event to the file-edit handler instead of only PostToolUse edits; upstream tool schema change renaming file_path to path or absolute_path; constructing NormalizedHookInput manually and forgetting filePath.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 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/5310a8dadf58b10a.
Report an issue: GitHub.
Appendix: source
Thrown at src/cli/handlers/file-edit.ts:15
import type { EventHandler, NormalizedHookInput, HookResult } from '../types.js';
import { executeWithWorkerFallback, isWorkerFallback } from '../../shared/worker-utils.js';
import { logger } from '../../utils/logger.js';
import { HOOK_EXIT_CODES } from '../../shared/hook-constants.js';
import { normalizePlatformSource } from '../../shared/platform-source.js';
import { shouldTrackProject } from '../../shared/should-track-project.js';
export const fileEditHandler: EventHandler = {
async execute(input: NormalizedHookInput): Promise<HookResult> {
const { sessionId, cwd, filePath, edits } = input;
const platformSource = normalizePlatformSource(input.platform);
if (!filePath) {
throw new Error('fileEditHandler requires filePath');
}
logger.dataIn('HOOK', `FileEdit: ${filePath}`, {
editCount: edits?.length ?? 0
});
if (!cwd) {
throw new Error(`Missing cwd in FileEdit hook input for session ${sessionId}, file ${filePath}`);
}
if (!shouldTrackProject(cwd)) {
logger.debug('HOOK', 'Project excluded from tracking, skipping file edit observation', { cwd, filePath });
return { continue: true, suppressOutput: true, exitCode: HOOK_EXIT_CODES.SUCCESS };
}
const result = await executeWithWorkerFallback<{ status?: string }>(
'/api/sessions/observations',
'POST',View on GitHub (pinned to d8bc9755e7)