Skip to content

fix(config): parse partial sub-config sections - #1483

Open
Jitsusama wants to merge 1 commit into
rtk-ai:developfrom
Jitsusama:fix/config-serde-default-sub-structs
Open

Jitsusama wants to merge 1 commit into
rtk-ai:developfrom
Jitsusama:fix/config-serde-default-sub-structs

Conversation

@Jitsusama

Copy link
Copy Markdown

Summary

Fixes #1482.

  • Five sub-config structs (TrackingConfig, DisplayConfig, FilterConfig, TelemetryConfig and LimitsConfig) don't have #[serde(default)], so any partial TOML section fails to parse with missing field. Config::load returns the error, helpers like config::limits call .unwrap_or_default(), and the user's explicit overrides are silently replaced by the full default config.
  • Add struct-level #[serde(default)] to each of the five structs. Every one of them already implements Default with the correct domain values, so the attribute delegates to what's already there. No logic changes, no duplicated defaults, backward compatible with fully specified configs.

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets && cargo test: 1684 passed, 0 failed.
  • Six new tests in src/core/config.rs::tests:
    • test_partial_tracking_section_uses_defaults
    • test_partial_display_section_uses_defaults
    • test_partial_filters_section_uses_defaults
    • test_partial_telemetry_section_uses_defaults
    • test_partial_limits_section_uses_defaults
    • test_full_limits_section_roundtrip (regression guard for fully specified sections)

Files Changed

File Change
src/core/config.rs Add struct-level #[serde(default)] to five sub-config structs; add six parsing tests.

Related


Co-Authored-By AI (Claude Opus 4.7) via Pi

Five sub-config structs (TrackingConfig, DisplayConfig,
FilterConfig, TelemetryConfig and LimitsConfig) don't have
#[serde(default)], so any TOML section that omits a field
fails to parse with a "missing field" error. The error
bubbles up to Config::load, and helpers like limits() call
.unwrap_or_default() on the Result, which silently swaps in
the full default config and throws away every user override.

Say someone writes this:

    [limits]
    grep_max_results = 500

They expect grep_max_results to be 500 with the rest of the
limits at their defaults. What they actually get is
grep_max_results back at 200 because the partial section
never parsed in the first place.

The fix is to add struct-level #[serde(default)] to each of
the five structs. Every one of them already has a Default
impl with the correct domain values, so the attribute just
delegates to what's already there. No logic moves, no
behaviour changes for fully specified configs, and partial
sections now do what users expect.
@CLAassistant

CLAassistant commented Apr 24, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier good first issue Good for newcomers labels Apr 24, 2026
@pszymkowiak

Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Adds #[serde(default)] to five sub-config structs (TrackingConfig, DisplayConfig, FilterConfig, TelemetryConfig, LimitsConfig) so that partially specified TOML sections parse correctly by falling back to each struct's existing Default impl. Includes six new tests covering partial and full config section parsing.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1482


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants