fix: exclude blank account_ref from engine preview aggregate (#93)#95
fix: exclude blank account_ref from engine preview aggregate (#93)#95agent-p1p wants to merge 1 commit into
Conversation
group_engine_preview() used Min("account_ref"), which returns "" for any
engine that has at least one event without an account_ref, since the empty
string sorts before any hex value. The shell preview then rendered a blank
account for an engine that actually has one, disagreeing with
timeline_engines() (which keeps the first non-empty account_ref).
Add filter=~Q(account_ref="") to the aggregate so a real account_ref is
reported whenever the engine has one, falling back to "" (via the existing
row["account_ref"] or "") only when every event is blank. This matches the
timeline's first/any-non-empty semantics.
Adds two regression tests covering the mixed present/absent case and the
all-blank fallback.
Closes #93
|
Warning Review limit reached
More reviews will be available in 5 minutes and 30 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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 |
|
Ready to review this PR? Stage has broken it down into 2 individual chapters for you:
Chapters generated by Stage for commit 042b805 on Jun 22, 2026 12:28pm UTC. |
Adversarial review: no PR-diff blockersI reviewed PR #95 against issue #93. Findings:
What I checked:
Local verification:
CI note:
|
Closes #93
Summary
group_engine_preview()(forensics/views.py) annotatedaccount_ref=Min("account_ref"). Becauseaccount_refis a blank-ableCharFieldand the empty string sorts before any hex value, an engine with any event lacking anaccount_refgot""from the aggregate — so the group-detail header engine chips rendered a blank account for an engine that actually has one. Meanwhiletimeline_engines()(forensics/analysis.py:907) keeps the first non-emptyaccount_ref, so the same engine showed its real account in the timeline column. The two paths disagreed.The fix adds
filter=~Q(account_ref="")to the aggregate so the preview reports a realaccount_refwhenever the engine has one, and falls back to""(via the existingrow["account_ref"] or "") only when every event for the engine is blank — exactly matching the timeline's first/any-non-empty semantics.Qwas already imported.Changes
forensics/views.py— one-line aggregate change (+ explanatory comment).forensics/tests.py— two regression tests:account_reffor one engine -> preview reports the real ref""Verification
Run locally with
DJANGO_DEBUG=1:uv run ruff check .-> All checks passeduv run ruff format --check .-> 19 files already formatteduv run python manage.py test-> 149 tests OK (SQLite)Min("account_ref")(AssertionError: '' != 'aaaa...') and passes with the fix.Pre-existing master breakage (NOT this PR)
mastercurrently has a conflicting migration graph — two leaf nodesforensics/migrations/0007_add_auditevent_line_hash_engine_index(from #87) and0007_auditfile_groups(from #80) both branch off0006with no merge migration. This makesmanage.py testandmakemigrations --checkfail on master itself (master CI for #87 is red on theRun testsstep). This PR's CI will be red for the same reason — it is unrelated to #93 and not introduced here. To run the suite locally I created a throwaway--mergemigration, verified all 149 tests pass, then discarded it (not committed). The migration conflict needs a separate fix (a merge migration under the sensitive**/migrations/**path); it is intentionally out of scope for this display-correctness fix.Sensitive paths
None touched. (
forensics/views.py,forensics/tests.pyonly.)