Conversation
… validator Add comprehensive config validation system with two-layer approach: - mapstructure Metadata for key presence detection (unknown keys, deprecated options) - go-playground/validator/v10 for struct value validation with custom validators Key changes: - Add DecodeResult tracking used/unused keys during INI parsing - Add custom validators for cron expressions and Docker image references - Enhance deprecation detection to use key presence (poll-interval, no-poll) - Add Levenshtein-based "did you mean?" suggestions for typos - Centralize deprecation handling, remove distributed warning code - Add validation tags to Global and DockerConfig structs Includes ADR-003 documenting the design decision.
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
✅ Mutation Testing ResultsMutation Score: 79.17% (threshold: 60%)
What is mutation testing?Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.
|
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive configuration validation system for Ofelia with a two-layer approach: mapstructure metadata for key presence detection and go-playground/validator/v10 for struct value validation. The key improvement is the ability to detect deprecated configuration options even when set to zero values (e.g., poll-interval = 0), which was previously missed. It also adds Levenshtein-based "did you mean?" suggestions for typos in configuration keys and centralizes all deprecation handling.
Key Changes
- New validation infrastructure: Added
cli/config_decode.gofor metadata tracking during INI parsing andcli/config_validate.gowith custom validators for cron expressions and Docker image references - Centralized deprecation system: Created
cli/deprecations.gowith a registry that uses key presence detection instead of just value checking, enabling detection of zero-value deprecated options - Enhanced user feedback: Implements Levenshtein distance algorithm for suggesting corrections to typo'd configuration keys
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Adds go-playground/validator/v10 dependency and related packages |
| go.sum | Dependency checksums for new validator packages |
| middlewares/slack.go | Removes distributed deprecation warning code in favor of centralized handling |
| cli/deprecations.go | New centralized deprecation registry with presence-based detection |
| cli/deprecations_test.go | Comprehensive tests for deprecation detection and migration |
| cli/config_decode.go | New decoder that tracks used/unused keys during INI parsing |
| cli/config_decode_test.go | Tests for metadata tracking and key normalization |
| cli/config_validate.go | Validation infrastructure with custom cron and dockerimage validators, plus Levenshtein distance for typo suggestions |
| cli/config_validate_test.go | Tests for validators and suggestion algorithm |
| cli/config.go | Integrates new decoder and adds validation tags to Config/DockerConfig structs |
| cli/docker_config_handler.go | Removes deprecation migration logic (now handled centrally) |
| cli/docker_handler_test.go | Updates tests to use new centralized migration system |
| cli/doctor.go | Adds deprecation checking to doctor command output |
| docs/adr/ADR-003-config-validation-improvements.md | Architecture Decision Record documenting the design and implementation |
| docs/adr/README.md | Adds ADR-003 to the index |
Rewrites ADR-003 to follow proper ADR conventions: - Remove implementation plan sections (ADRs document decisions, not plans) - Remove test plan section - Fix DecodeResult struct to match implementation (UsedKeys/UnusedKeys only) - Document Levenshtein distance as part of the decision, not future work - Add Scope Limitations section documenting current job section limitation - Change status from Proposed to Accepted Addresses Copilot review comments on PR #432.
## Summary - Rewrite ADR-003 to follow proper ADR conventions (decisions, not plans) - Remove implementation plan and test plan sections - Fix DecodeResult struct to match implementation - Document Levenshtein distance as part of the decision - Add Scope Limitations section for job section limitation - Update status from Proposed to Accepted ## Addresses Copilot review comments from PR #432: - DecodeResult struct mismatch - Levenshtein phase placement - Job sections unknown key limitation ## Test plan - [x] ADR follows proper format (Context, Decision, Consequences) - [x] README index updated with Accepted status
Summary
Key Changes
DecodeResulttracking used/unused keys during INI parsingcronanddockerimagevalidators, unknown key warning generationKeyNamefield for presence-based detectionTest plan
config_decode_test.go)config_validate_test.go)deprecations_test.go)