fix: prevent infinite recursion in validateSchema for non-object schema entries

migrateConfig stamps a version string into config schemas. validateSchema
then iterates the string's character indices, causing infinite recursion.
Skip the 'version' key and guard against any non-object schema entries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
znetsixe
2026-04-01 08:44:48 +02:00
parent f96476bd23
commit 13d1f83a85

View File

@@ -95,11 +95,19 @@ class ValidationUtils {
// Validate each key in the schema and loop over wildcards if they are not in schema // Validate each key in the schema and loop over wildcards if they are not in schema
for ( const key in schema ) { for ( const key in schema ) {
if (key === "rules" || key === "description" || key === "schema") { if (key === "rules" || key === "description" || key === "schema" || key === "version") {
continue; continue;
} }
const fieldSchema = schema[key]; const fieldSchema = schema[key];
// Skip non-object schema entries (e.g. primitive values injected by migration)
if (fieldSchema === null || typeof fieldSchema !== 'object') {
this.logger.debug(`${name}.${key} has a non-object schema entry (${typeof fieldSchema}). Skipping.`);
validatedConfig[key] = fieldSchema;
continue;
}
const { rules = {} } = fieldSchema; const { rules = {} } = fieldSchema;
// Default to the schema's default value if the key is missing // Default to the schema's default value if the key is missing