fix(lifecycle): date-only --before crashes clear on every surface - #580
fix(lifecycle): date-only --before crashes clear on every surface#580kai392 wants to merge 2 commits into
Conversation
`clear_claims` compared a caller-supplied `before` straight against a claim's `created_at`. a date-only cutoff parses naive, `created_at` is always aware, and python refuses to order the two — so the documented shape raised `TypeError` instead of filtering. `2026-07-01` is exactly what the cli help, the console's inline error text, and the kb.clear docs advertise, so the crash sits on the happy path of all four surfaces: a traceback out of `vouch claims-clear --before`, an error response over mcp and jsonl, and an unhandled 500 on the review console's `/clear-claims` (the handler only catches `HTTPException`). normalised once at the `lifecycle.clear_claims` chokepoint with the same `_utc` helper stats.py, proposals.py, and digest.py already use, so every surface is fixed without touching a transport. an aware cutoff keeps its existing behaviour; the audit event now records the normalised cutoff so the logged value is unambiguous. the regression lives in a new tests/test_lifecycle.py rather than tests/test_clear_claims.py — that module skips without numpy, which the base ci job does not install.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesClaim clear UTC handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
|
the |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@CHANGELOG.md`:
- Around line 297-304: Move the described clear-claims timezone normalization
bullet from the released 1.4.0 section into the [Unreleased] section of
CHANGELOG.md, preserving its wording and formatting.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: adf93c2d-04d2-4e14-aebb-fb0784cd04ec
📒 Files selected for processing (4)
CHANGELOG.mdsrc/vouch/lifecycle.pytests/test_lifecycle.pytests/test_web.py
|
good catch, fixed in a90dff0. the bullet was sitting in the released |
|
coderabbit approved a90dff0. the so this needs one "approve and run workflows" click to go green; nothing on my side is outstanding. the fork run of the same workflow on the identical tree was green end to end (lint, |
it landed in the released 1.4.0 block — i checked the next ## header below the entry and not the one above it, so the bullet would have been missing from the next release notes.
What changed
lifecycle.clear_claimsnormalises itsbeforecutoff to utc beforecomparing it against a claim's
created_at, using the same_utchelperstats.py,proposals.py, anddigest.pyalready use. one chokepoint, sothe cli, the mcp tool, the jsonl handler, and the review console are all
fixed without touching a transport. the
claim.bulk_clearaudit event nowrecords the normalised cutoff instead of whatever shape the caller passed.
Why
the comparison was
claim.created_at >= before.created_atis alwaystz-aware; a date-only cutoff parses naive, and python refuses to order the
two — so the call raised
TypeError: can't compare offset-naive and offset-aware datetimesbefore filtering anything.2026-07-01is not an unusual input, it is the exact shape the code itselfadvertises: the cli's
invalid date formatmessage, the console's inlineuse ISO 8601, e.g. 2026-07-01error, and the kb.clear docs all name it. sothe crash sits on the documented happy path of every surface:
vouch claims-clear --before 2026-07-01→ tracebackkb.clearover mcp / jsonl → error response, nothing clearedGET|POST /clear-claims?before=2026-07-01→ unhandled 500; the view onlycatches
HTTPException, so theTypeErrorescapes both handlersrepro on
testbefore the fix:What might break
nothing on disk. no file moves, no field changes shape, no
kb.*signaturechanges. an aware
beforekeeps its exact current behaviour —_utcis ano-op on anything already tz-aware, so existing callers and the current
tests are unaffected. the only behaviour change is that a naive cutoff now
filters (read as utc) instead of raising, and the audit event's
beforefield is written normalised.
VEP
not a surface change — no vep.
Tests
make checkpasses locally (lint + mypy + pytest)CHANGELOG.mdupdated under## [Unreleased]two regressions, both failing on the previous code with the
TypeErrorabove:
tests/test_lifecycle.py::test_clear_claims_reads_a_naive_before_as_utc—the unit case, plus the audit event's normalised cutoff. filed in a new
tests/test_lifecycle.pyrather thantests/test_clear_claims.pybecausethat module's autouse fixture
importorskips numpy, which the base ci job(
pip install -e '.[dev,web]') does not install — the whole file isskipped there, so a regression parked in it would never run in ci.
tests/test_web.py::test_clear_date_only_before_does_not_500— the consolepath, asserting 200 on the preview and 303 + archived on the apply.
validation run:
no ui files are touched (
web/,src/vouch/web/,webapp/are alluntouched), only
tests/test_web.py, so there is no screenshot to add.Summary by CodeRabbit
Bug Fixes
--beforeparsing for claim clearing by treating naive inputs as UTC./clear-claimsflow no longer crashes for date-onlybeforevalues.Tests
before=YYYY-MM-DD.