Skip to content

fix(stats): skip corrupt decided/*.yaml so vouch stats cannot crash - #673

Merged
plind-junior merged 2 commits into
vouchdev:testfrom
kai392:fix/critical-issue-stats-decided-skip
Jul 30, 2026
Merged

fix(stats): skip corrupt decided/*.yaml so vouch stats cannot crash#673
plind-junior merged 2 commits into
vouchdev:testfrom
kai392:fix/critical-issue-stats-decided-skip

Conversation

@kai392

@kai392 kai392 commented Jul 30, 2026

Copy link
Copy Markdown

Summary

Root cause: stats._list_decided() — used by review_summary / collect_stats (vouch stats, kb.stats) — parsed every decided/*.yaml strictly. One corrupt or hand-edited decided file raised an unhandled exception and aborted the whole stats surface.

Meanwhile KBStore.list_proposals() already uses _load_or_skip, and list_pages() gained the same resilience in #360. _list_decided was the leftover outlier.

Fix: Use _load_or_skip when loading decided proposals. One bad file logs a warning and is skipped; valid decisions still count.

Impact: vouch stats / kb.stats keep working when a single decided proposal YAML is unreadable.

Reproduction

# After one successful approve, plant garbage under decided/:
(store.kb_dir / "decided" / "corrupt.yaml").write_text("not: [valid\n")
stats.review_summary(store, since_days=None)
# before: yaml.ParserError
# after:  approved count still includes the good decision

Risk / tradeoffs

  • Corrupt decided files are omitted from review totals (same behavior as corrupt pending proposals via list_proposals). Audit-based audit_totals in the same response are unaffected.

Test plan

  • test_review_summary_skips_corrupt_decided_file (new)
  • tests/test_stats.py pass

@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 30, 2026
jak-glitch and others added 2 commits July 31, 2026 04:00
_list_decided parsed every decided/*.yaml strictly, so one bad file
took down vouch stats / kb.stats. Skip unreadable files via _load_or_skip
like list_proposals already does.

Co-authored-by: Cursor <cursoragent@cursor.com>
@plind-junior

Copy link
Copy Markdown
Member

@kai392 Next time, raise the issue on GH for such kinda valid discoveries. It's worth to be rewarded as a discovery

@plind-junior
plind-junior enabled auto-merge July 30, 2026 21:39
@plind-junior
plind-junior disabled auto-merge July 30, 2026 22:00
@plind-junior
plind-junior merged commit 9b07708 into vouchdev:test Jul 30, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation, specs, examples, and repo guidance size: XS less than 50 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants