Hive Hive
Sign in

Backfill project_id on first_run test_case_events rows left at the zero sentinel

GitHub issue · Open

Metadata
Source
tuist/tuist #12216
Updated
Aug 4, 2026
Domains
Testing
Details

Context

test_case_events.project_id (Int64 DEFAULT 0, denormalized in migration 20260721115000) is now relied on for project-scoped reads: PR #12215 scopes the quarantined-tests aggregate on it. While validating that PR we confirmed every state-change event type (muted, skipped, unmuted, unskipped, marked_flaky, unmarked_flaky) carries a real project_id — but first_run events do not: a subset of them still sit at the project_id = 0 sentinel.

How the zeros got there

Two populations, neither ongoing:

  1. Orphans predating the backfill. The 20260721115000 mutation resolved project_id through a dictionary built from test_cases; first_run rows whose test case had since been deleted resolved to the 0 default and were left as-is.
  2. A post-backfill write window. create_first_run_events has set project_id: run.project_id since #11977, but zero-rows continued for roughly a week after the backfill before stopping abruptly — consistent with a lagging ingestion component (e.g. the separately-shipped xcresult-processor image) still running a pre-#11977 release. A portion of these rows belong to test cases that still exist, so they are cleanly fixable.

No zero-rows have been written since; the current write path is correct.

Impact

None today: first_run is an audit-log-only event type, and its reads are scoped by test_case_id. But the column now looks uniformly trustworthy — every other event type is fully backfilled — so the next project-scoped query over events (exactly what PR #12215 added for muted/skipped) would silently miss these rows. This is a data-hygiene trap worth closing while the context is fresh.

Proposed fix

  1. Re-run the dictionary backfill mutation from 20260721115000 (same advisory-lock pattern) for event_type = 'first_run' AND project_id = 0 — this fixes the post-backfill window rows whose test cases exist.
  2. Decide on the true orphans (test case no longer in test_cases): either delete them (they can never render in any UI that starts from a test case) or document that project_id = 0 on first_run means “orphaned audit row”.

Out of scope

PR #12215 is unaffected: its scoped subquery reads only muted/skipped events (fully backfilled, zero mismatches against the owning test case’s project), and the flaky-tests subquery scopes by test_case_id.

🤖 Generated with Claude Code

Flights

Investigate, reproduce, or fix this item in an isolated repository. Each Flight preserves its outcome and agent session.

New Flights are paused Configure model inference, GitHub, and a sandbox provider to start another Flight. Existing results remain available below.
No Flights yet

Start a Flight and preserve its objective, outcome, and session here.

Comments

No GitHub comments yet.