mirror of
https://github.com/rehan-remade/universal-modder.git
synced 2026-11-05 01:37:40 +00:00
[PR #66] [MERGED] fix(kb): report an impossible front-matter date instead of crashing #96
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rehan-remade/universal-modder#96
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/rehan-remade/universal-modder/pull/66
Author: @kevin9327
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @rehan-remade
Base:
main← Head:fix/kb-invalid-date📝 Commits (3)
2118fedfix(kb): report an impossible front-matter date instead of crashingeecddfcMerge main into fix/kb-invalid-date and regenerate the kb indexa12cc7atest: check the error prefix, not Python's date message📊 Changes
2 files changed (+13 additions, -1 deletions)
View changed files
📝
tests/test_um.py(+12 -0)📝
um/kb.py(+1 -1)📄 Description
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)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.