fix(config): preserve config data when validation fails

When readConfigFileSnapshot encounters validation errors, it now:
1. Returns the resolved config data instead of empty object
2. Uses passthrough() on main schema to preserve unknown fields

This prevents config loss when:
- User has custom/unknown fields
- Legacy config issues are detected but config is otherwise valid
- Zod schema does not recognize newer fields

Fixes config being overwritten with empty object on validation failure.
This commit is contained in:
Muhammed Mukhthar CM
2026-01-12 06:22:59 +00:00
committed by Peter Steinberger
parent b32f6a0e00
commit 20ba8d4891
3 changed files with 45 additions and 1 deletions

View File

@@ -1757,6 +1757,7 @@ export const ClawdbotSchema = z
})
.optional(),
})
.passthrough()
.superRefine((cfg, ctx) => {
const agents = cfg.agents?.list ?? [];
if (agents.length === 0) return;