-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Description
Summary
Implement comprehensive validation for configuration file values to prevent runtime errors from invalid settings. Add validation for timeout values, percentages, URLs, colors, enums, and other configuration parameters with helpful error messages.
Files to modify
src/theme/config/settings_ensure.rs(add validation functions)src/theme/config/theme_loader.rs(add color format validation)src/theme/config/keybinds_loader.rs(if exists, add keybind validation)src/theme/types.rs(add validation methods to Settings struct)
Expected behavior
When invalid configuration values are detected:
- Show clear, actionable error messages explaining what's wrong
- Suggest valid alternatives or ranges where applicable
- Fall back to default values for individual invalid settings
- Allow the application to start with partially valid configuration
- Log warnings for invalid values that were corrected
Implementation approach
-
Add validation functions:
validate_layout_percentages()- ensure left/center/right sum to 100validate_timeout_values()- check updates_refresh_interval is reasonablevalidate_age_limits()- validate news age limits are positivevalidate_mirror_count()- ensure mirror_count is reasonablevalidate_color_formats()- verify hex/RGB color formatsvalidate_enum_values()- check sort_mode, package_marker are validvalidate_locale()- verify locale is supported or empty
-
Integrate validation:
- Call validation during config loading in
settings_ensure.rs - Return detailed error messages with suggestions
- Fall back to defaults for invalid individual values
- Continue with valid configuration values
- Call validation during config loading in
-
Error messaging:
- Include the invalid value and line number where possible
- Suggest valid alternatives (e.g., "use 30 instead of -5")
- Explain the constraint (e.g., "must be between 1-3600 seconds")
Testing
-
cargo checkpasses -
cargo clippy --all-targets --all-features -- -D warningspasses -
cargo test -- --test-threads=1passes - Test validation of invalid layout percentages (don't sum to 100)
- Test validation of negative timeout values
- Test validation of invalid color formats (#GGG, invalid hex)
- Test validation of unsupported enum values
- Test validation of invalid locale codes
- Test fallback behavior when some values are invalid
- Test error messages contain helpful suggestions
Additional context
Configuration values that need validation:
- Layout percentages:
layout_left_pct,layout_center_pct,layout_right_pctmust sum to 100 - Timeouts:
updates_refresh_intervalshould be 1-3600 seconds - Age limits:
news_max_age_days,startup_news_max_age_daysshould be positive or None - Mirror count:
mirror_countshould be 1-100 - Colors: All theme colors should be valid hex (#RRGGBB) or RGB (R,G,B) format
- Enums:
sort_mode,package_marker,installed_packages_modeshould be valid variants - Locale: Should be empty, "en-US", "de-DE", or "hu-HU"
- URLs: Any URL fields should be valid URLs (though none currently exist)
Follow existing error handling patterns in the codebase. Validation should be non-blocking - invalid individual values should fall back to defaults while preserving valid configuration.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed