This guide explains how Minsky handles configuration validation, including the new flexible validation system that gracefully handles unknown configuration fields.
Minsky's configuration system now supports flexible validation that allows unknown configuration fields while still validating known fields strictly. This enables forward compatibility and graceful handling of experimental or provider-specific configuration options.
- Unknown fields: Allowed with warnings
- Known fields: Strictly validated
- Behavior: Configuration loads successfully even with unknown fields
- Unknown fields: Rejected with errors
- Known fields: Strictly validated
- Behavior: Configuration fails to load if unknown fields are present
Control validation behavior through the validation section in your configuration:
# Configuration validation settings
validation:
# Whether to use strict validation (reject unknown fields)
strictMode: false
# Whether to show warnings for unknown configuration fields
warnOnUnknown: true
# Whether to show path information in unknown field warnings
includePathInWarnings: true
# Whether to include the validation error code in warnings
includeCodeInWarnings: falseYou can also control validation via environment variables:
# Enable strict mode
export MINSKY_VALIDATION_STRICT_MODE=true
# Disable warnings for unknown fields
export MINSKY_VALIDATION_WARN_ON_UNKNOWN=false
# Include detailed path information in warnings
export MINSKY_VALIDATION_INCLUDE_PATH_IN_WARNINGS=true
# Include validation error codes in warnings
export MINSKY_VALIDATION_INCLUDE_CODE_IN_WARNINGS=trueConfiguration:
ai:
providers:
openai:
enabled: true
apiKey: sk-...
morph: # Unknown provider
enabled: true
apiKey: sk-...Result:
- ✅ Configuration loads successfully
⚠️ Warning logged: "Unknown configuration field detected"- 🚀 Application continues normally
Log Output:
Warning: Unknown configuration field detected { path: "ai.providers", message: "Unrecognized key(s) in object: 'morph'" }
Configuration:
validation:
strictMode: true
ai:
providers:
openai:
enabled: true
apiKey: sk-...
morph: # Unknown provider
enabled: true
apiKey: sk-...Result:
- ❌ Configuration fails to load
- 🛑 Application startup blocked
- 📝 Clear error message provided
Configuration:
validation:
warnOnUnknown: false
ai:
providers:
morph: # Unknown provider
enabled: true
apiKey: sk-...Result:
- ✅ Configuration loads successfully
- 🔇 No warnings logged
- 🚀 Application continues normally
If you were relying on strict validation behavior (configurations failing on unknown fields), you need to explicitly enable strict mode:
Before (automatic strict validation):
# Unknown fields would cause startup failure
ai:
providers:
custom_provider: { ... } # This would failAfter (explicit strict mode):
validation:
strictMode: true # Restore previous behavior
ai:
providers:
custom_provider: { ... } # This will still fail as expectedThe new system makes it easier to experiment with new AI providers:
ai:
providers:
# Standard providers
openai:
enabled: true
apiKey: sk-...
# Experimental providers (will generate warnings but won't break startup)
experimental_provider:
enabled: true
apiKey: sk-...
custom_option: valuevalidation:
strictMode: false # Allow experimentation
warnOnUnknown: true # Show warnings for debugging
includePathInWarnings: true # Detailed path information
includeCodeInWarnings: true # Include error codes for debuggingvalidation:
strictMode: true # Strict validation for stability
warnOnUnknown: true # Log any unexpected fields
includePathInWarnings: true # Helpful for troubleshooting
includeCodeInWarnings: false # Cleaner logsvalidation:
strictMode: true # Catch configuration issues early
warnOnUnknown: true # Log warnings for analysis
includePathInWarnings: true # Full diagnostic information
includeCodeInWarnings: true # Complete error detailsSymptom:
Warning: Unknown configuration field detected { path: "ai.providers", message: "Unrecognized key(s) in object: 'morph'" }
Solutions:
- If expected: Continue using the configuration (warnings are informational)
- If typo: Fix the field name to match a supported provider
- If unwanted: Remove the unknown field
- If disruptive: Set
warnOnUnknown: falseto silence warnings
Symptom:
Configuration validation failed: ai.providers: Unrecognized key(s) in object: 'morph'
Solutions:
- Disable strict mode: Set
validation.strictMode: false - Fix configuration: Remove or correct the unknown fields
- Update Minsky: Check if the field is supported in a newer version
- Validation overhead: Minimal impact on startup time
- Logging overhead: Warnings logged only during startup
- Memory usage: No significant increase
- Parse configuration from all sources (files, environment, defaults)
- Merge configurations with proper precedence
- Apply validation rules based on validation configuration
- Filter errors into critical vs. unknown field issues
- Log warnings for unknown fields (if enabled)
- Return result with appropriate success/failure status
- Critical errors: Type mismatches, required fields missing, invalid values
- Unknown field errors: Fields not recognized by current schema
- Warning-level issues: Unknown fields when not in strict mode
- Default behavior: Permissive (allows unknown fields)
- Explicit opt-in: Strict mode available via configuration
- Graceful degradation: Unknown fields preserved in configuration object
- API compatibility: Existing code continues to work unchanged
For questions about configuration validation:
- Check logs: Look for validation warnings and error details
- Review configuration: Verify field names and structure
- Consult documentation: Check provider-specific configuration guides
- Test validation: Use different validation modes to diagnose issues