fix(config): fall back to defaults on malformed numeric config values - #488
Conversation
recall.load_config and capture.load_config both document "read the namespace; fall back to defaults" but only guarded the read of config.yaml itself, not the int()/float() coercion of individual values. a typo like `max_chars: a lot` raised an uncaught ValueError straight out of the SessionStart recall hook; the same shape of typo in capture: crashed observe()/finalize(). compile.load_config already solved this with a small _coerce(value, default, cast) helper (see the comment at compile.py:64-70) and has a test proving it. mirror that pattern in recall.py and capture.py so all three load_config functions honor the same fallback contract, and add the matching regression tests. validated: pytest tests/ -q --ignore=tests/embeddings, mypy src, ruff check src tests all pass.
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
closing this as stale — the branch no longer merges cleanly into conflicting files:
this isn't a judgement on the change itself — the base has just moved far enough that the merge can't be resolved automatically any more. if you still want it in, rebase onto current thanks for the contribution. |
recall.load_config and capture.load_config passed YAML-sourced numeric fields (max_chars, min_observations, dedup_window_seconds) straight through bare int()/float(), raising ValueError on a config typo like max_chars: "12,000" instead of degrading to the default the way the same modules' enabled boolean already does via coerce_bool. recall.load_config backs the SessionStart hook with no exception handling around the call, so one bad numeric value took down recall injection on every new session; capture.load_config backs session-split capture and codex rollout ingestion the same way. compile.py already implemented this fail-soft contract for its own numeric fields via a local _coerce(value, default, cast) helper. promote it into the shared config_coerce.py module as coerce_numeric, alongside the existing coerce_bool, and use it in recall.py and capture.py's load_config functions, removing the now-redundant local copy in compile.py. new tests confirm a malformed numeric value degrades to the default in both recall and capture rather than raising. this exact defect and fix were previously submitted as #488 (CodeRabbit-reviewed, no substantive objections), but that PR was closed unmerged for going stale against a fast-moving test branch, not for anything wrong with the change; the maintainer's closing comment explicitly invited a fresh PR. Fixes #685
what changed:
recall.load_configandcapture.load_confignow route their numeric config values (max_chars,min_observations,dedup_window_seconds) through a small_coerce(value, default, cast)helper instead of a bareint()/float()call, so a malformed value falls back to the default instead of raising.why: both docstrings already promise "read the
<namespace>:stanza; fall back to defaults," andcompile.load_configalready implements exactly that contract with a_coercehelper (seecompile.py:64-70, added for the same reason — a config typo must degrade, not take down every caller).recall.pyandcapture.pyonly guarded the yaml read/parse, not the per-field coercion, so a config typo likemax_chars: a lotraised an uncaughtValueErrorstraight out of the SessionStart recall hook, and the equivalent typo undercapture:crashed any hook-drivenobserve()/finalize()call. this mirrors the existing, tested pattern rather than introducing a new one.nothing on disk changes shape — no migration impact, no effect on an existing
.vouch/directory. behavior only changes for the malformed-value case, which previously crashed.validation commands run:
.venv/bin/python -m pytest tests/ -q --ignore=tests/embeddings(full suite, all green).venv/bin/python -m mypy src(clean).venv/bin/python -m ruff check src tests(clean)ValueErroron the pre-fix code (stashed the src changes, reran) and pass with the fix restored