Skip to content

fix(api): deterministic seed for collaborator notification test (flaky on main)#943

Merged
raymondjacobson merged 1 commit into
mainfrom
claude/collab-notif-test-fix
Jun 9, 2026
Merged

fix(api): deterministic seed for collaborator notification test (flaky on main)#943
raymondjacobson merged 1 commit into
mainfrom
claude/collab-notif-test-fix

Conversation

@raymondjacobson

Copy link
Copy Markdown
Member

Fixes the flaky TestTrackCollaboratorNotificationsGenerated failing on main.

Root cause

The notification trigger's "new pending invite" branch fires only when created_at = updated_at (this is how it tells a fresh ETL insert from a reconcile re-write — the ETL writes them equal on insert). seedCollaborators didn't set those columns, so it inherited the seed baseRow defaults, which call time.Now() twice:

"created_at": time.Now(),
"updated_at": time.Now(),

After the timestamp column truncates to microseconds, those two calls are equal only if both landed in the same microsecond — a per-CI-run coin flip (the baseRow is a package var, initialized once). My local/isolated runs won the toss; CI lost it, so the trigger didn't fire and the test saw 0 notifications. (I'd earlier misattributed this to the unrelated TestSearch Elasticsearch panic — apologies.)

Fix

Pin a single now for both created_at and updated_at in the seed, so the invite branch always fires. Deterministic — passes 5× in a row locally, plus the full collaborator suite.

Note

The shared track_collaborators baseRow in database/seed.go still has the two-time.Now() default (latent, same as grants); not touched here to keep the fix scoped, since the only seeder that depends on the equality is now explicit.

🤖 Generated with Claude Code

TestTrackCollaboratorNotificationsGenerated was flaky: the notification
trigger's "new pending invite" branch fires only when created_at = updated_at
(mirroring the ETL, which writes them equal on insert). seedCollaborators
relied on the seed baseRow defaults, which call time.Now() twice — those
round-trip equal through the timestamp column only when both calls land in the
same microsecond, so the test passed or failed per CI run by luck.

Pin a single timestamp for both columns in the seed so the invite notification
always fires. Passes 5x in a row.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@raymondjacobson raymondjacobson merged commit c9d95c7 into main Jun 9, 2026
5 checks passed
@raymondjacobson raymondjacobson deleted the claude/collab-notif-test-fix branch June 9, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant