Fix settings validation to properly respect additionalProperties: false

This commit is contained in:
Tianqi Zhang
2025-12-26 09:20:26 +08:00
committed by jacob314
parent f1ca7fa40a
commit 5e59eeea3f
@@ -54,9 +54,10 @@ function buildZodSchemaFromJsonSchema(def: any): z.ZodTypeAny {
}
shape[key] = propSchema;
}
schema = z.object(shape).passthrough();
// Don't apply passthrough() here - we'll determine the behavior below
schema = z.object(shape);
} else {
schema = z.object({}).passthrough();
schema = z.object({});
}
if (def.additionalProperties === false) {
@@ -65,6 +66,9 @@ function buildZodSchemaFromJsonSchema(def: any): z.ZodTypeAny {
schema = schema.catchall(
buildZodSchemaFromJsonSchema(def.additionalProperties),
);
} else {
// Default to passthrough when additionalProperties is not explicitly false
schema = schema.passthrough();
}
return schema;