thedotmack/claude-mem · warning
validation.error
Error message
validation.error
What it means
handleUpdateSettings runs the request body through this.validateSettings and, on failure, returns 400 with success:false and the specific validation error message. The 'validation.error' in the error record is the generic marker; the actual message comes from validateSettings.
Solutions
- Read the 'error' field of the 400 response — it names the offending setting and reason
- Correct the setting key/value to match the current settings schema
- GET the current settings first and modify only known-valid keys
- Update the client/script if the settings schema changed between versions
Example fix
// before
await fetch('/api/settings', { method: 'PUT', body: JSON.stringify({ autoCompact: 'yes' }) });
// after
await fetch('/api/settings', { method: 'PUT', body: JSON.stringify({ autoCompact: true }) }); Defensive patterns
Strategy: validation
Validate before calling
const current = await (await fetch('/api/settings')).json();
const next = { ...current, autoCompact: true }; // modify only known keys
// verify keys exist before sending
for (const k of Object.keys(changes)) if (!(k in current)) throw new Error(`Unknown setting: ${k}`); Type guard
function isSettingKey(k: string): k is keyof SettingsSnapshot {
return k in DEFAULT_SETTINGS;
} Try / catch
const res = await fetch('/api/settings', { method: 'PUT', body: JSON.stringify(changes) });
if (res.status === 400) {
const body = await res.json();
throw new Error(`Settings rejected: ${body.error}`);
} Prevention
- GET current settings and merge changes instead of posting a hand-built object
- Validate setting keys/values against the schema client-side before the PUT
- After version upgrades, diff your settings writes against the new schema
- Surface the response's 'error' string directly to users — it names the offending field
When it happens
Trigger: PUT/POST to the settings update route with a body containing an invalid setting key, out-of-range value, wrong type, or an unknown field rejected by validateSettings.
Common situations: Client UI or script writes a setting with a typo'd key; writing a number where a boolean/enum is expected; attempting to set a setting removed or renamed in a newer worker version; sending the whole settings object with stale fields.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17).
Data as JSON: /api/errors/4fbddc0c53b6b7cc.
Report an issue: GitHub.
Appendix: source
Thrown at src/services/worker/http/routes/SettingsRoutes.ts:93
app.get('/api/mcp/status', this.handleGetMcpStatus.bind(this));
app.post('/api/mcp/toggle', validateBody(toggleMcpSchema), this.handleToggleMcp.bind(this));
}
private handleGetSettings = this.wrapHandler((req: Request, res: Response): void => {
const settingsPath = paths.settings();
this.ensureSettingsFile(settingsPath);
const settings = SettingsDefaultsManager.loadFromFile(settingsPath);
res.json(redactSecretSettings(settings));
});
private handleGetDependencyHealth = this.wrapHandler((_req: Request, res: Response): void => {
res.json(snapshotDependencyHealth());
});
private handleUpdateSettings = this.wrapHandler((req: Request, res: Response): void => {
const validation = this.validateSettings(req.body);
if (!validation.valid) {
res.status(400).json({
success: false,
error: validation.error
});
return;
}
const settingsPath = paths.settings();
this.ensureSettingsFile(settingsPath);
let settings: any = {};
if (existsSync(settingsPath)) {
const settingsData = readFileSync(settingsPath, 'utf-8');
try {
settings = parseJsonWithBom(settingsData);
} catch (parseError) {
const normalizedParseError = parseError instanceof Error ? parseError : new Error(String(parseError));
logger.error('HTTP', 'Failed to parse settings file', { settingsPath }, normalizedParseError);
res.status(500).json({View on GitHub (pinned to d8bc9755e7)