Repository navigation
fix(kb): report an impossible front-matter date instead of crashing - #66
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Python 3.14 words the impossible-date ValueError differently from 3.12, so the test checks um's own "front matter is not valid YAML" prefix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Thanks! Merged. I changed one line in the test: Python 3.14 words the date error differently ("day 31 must be in range 1..30 for month 9"), so it now checks for "front matter is not valid YAML" instead. |
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.
kb.parse()only catchesyaml.YAMLError, but PyYAML buildsdatetime.dateobjects for unquotedYYYY-MM-DDvalues. A day that doesn't exist (date: 2026-09-31,2026-02-30, a swapped2026-30-09) raises a plainValueErrorfrom the constructor, so the error goes straight up to the user:Because
notes()parses every file, one such note also crashesum kb searchandum kb indexfor the whole knowledge base.check_notealready has a friendly path for broken front matter (front matter is not valid YAML: ...), and the date check further down never gets a chance to run.Change: catch
ValueErrornext toyaml.YAMLErrorinparse(), so the note is reported asfront matter is not valid YAML: day is out of range for monthand the other notes still search and index.Test:
test_kb_impossible_date_is_reported_not_raisedchecks the note's failure message and runssearch()andbuild_index()over a knowledge base containing it. It raisesValueErroronmainand passes with this change.Checklist
uv run --with pytest pytest -q testspasses (code)