fix(config): fall back to defaults on malformed numeric config values#488
Open
lourincedaging0-commits wants to merge 1 commit into
Open
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.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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