Skip to content

nightly: 1 production fix (2026-06-05) - #220

Closed
njrini99-code wants to merge 1 commit into
mainfrom
nightly-health-check/2026-06-05
Closed

nightly: 1 production fix (2026-06-05)#220
njrini99-code wants to merge 1 commit into
mainfrom
nightly-health-check/2026-06-05

Conversation

@njrini99-code

Copy link
Copy Markdown
Owner

Daily brief — 2026-06-05 (24h window)

Totals

Top patterns

# Sentry ID Events / Users Severity Diagnosis
1 JAVASCRIPT-NEXTJS-50 46 / 1 error (escalating) savePartialRound.updateExisting 42501s on every auto-save tick. Migration 20260603040000 (column GRANT for player_id/team_id/qualifier_id/qualifier_round_number) was committed in PR #217 but never applied to prod Supabase — repo applies migrations manually via MCP, no auto-apply step.
2 JAVASCRIPT-NEXTJS-4Z 46 / 0 error Mirrored server-side projection of #50. Same root cause, same trace.
3 JAVASCRIPT-NEXTJS-51 22 / 0 error Client-side wrapper of #50 (UI catches the server-action failure). Same root cause.
4 JAVASCRIPT-NEXTJS-57 5 / 0 error fetchShotDriversByCategory hits Postgres statement timeout on the IN-list-of-200-round-ids + nested joins query. Best-effort enrichment — page renders fine. Already addressed by in-flight PR #219 (demotes severity from error to warning to stop paging).
5 JAVASCRIPT-NEXTJS-58 2 / 0 error (new, 1h old) "Error updating shot: Auto-save server error". Same trace_id as #50 — edit-shot fans out into the same savePartialRound UPDATE path; same root cause.
6 JAVASCRIPT-NEXTJS-52 1 / 0 error "Error deleting shot: Auto-save server error". Single-occurrence; same root cause as #50.

Performance

Could not pull pg_stat_statements — Supabase MCP is unauthenticated in this remote session (Host-not-in-allowlist on the OAuth callback). No DB-side query timing available. The one timeout we DO see (issue #57) is the golf_shots shot-drivers query on /golf/dashboard/coachhelm (200 round_id IN-list + nested 1:1 joins, 5000-shot cap) — a known heavy query already gated by best-effort try/catch.

Deployment health

Deploy Commit State Notes
dpl_Bwpo7xDaXPMco9X1tDBPLBWQ17AT 22e1d32 READY (production) Carried the column-GRANT migration on disk but never applied to prod DB.
dpl_BQn2Ljknrf2Us1xXYZ3iFs2xu8d9 51dbc76 INITIALIZING (preview, PR #219) Severity-demotion for #57.

No Error-state deploys in the 24h window.


Fixes applied

1. golf_rounds auto-save 42501 cluster (#50 / #4Z / #51 / #58 / #52) — 117 of 122 events

File: src/app/golf/actions/golf.ts (around line 3911)
Diagnosis: savePartialRound constructs roundData with player_id/team_id/qualifier_id/qualifier_round_number every tick. On the fallback path (no existingRoundId passed, in-progress round found by query), it calls supabase.from('golf_rounds').update(roundData) directly. Postgres checks per-column UPDATE privilege on every column in the SET list regardless of whether the value differs from the current row — and the baseline authenticated GRANT intentionally omits identity columns. The previous fix migration 20260603040000 was shipped in the deploy commit but never applied to prod Supabase, so prod has been 42501-ing for ~22h on the same release SHA.

Fix: Strip the four identity columns from the UPDATE payload via object destructure. Identity columns are set on INSERT and don't change for an in-progress round — re-SETting them is gratuitous AND a permission liability. After the strip, this code path no longer depends on column grants for identity columns at all. RLS continues to scope rows.

2. Belt-and-suspenders migration

File: supabase/migrations/20260605040000_reaffirm_golf_rounds_update_grants.sql
Diagnosis: Same as #1 — the previous migration file exists on disk but is unapplied in prod. Restating the same GRANT under a fresh timestamp ensures the next supabase db push / MCP apply picks it up. Idempotent in Postgres, so a safe no-op if the prior was already applied.

NEEDS HUMAN STEP: Apply this migration to prod Supabase via the MCP (or supabase db push). The code change alone fixes the failing path even if the migration is never applied; this just brings the DB back to the documented end-state.


Couldn't fix / unresolved

  • Supabase MCP auth was rejected in this session (Host-not-in-allowlist on the OAuth callback URL), so I couldn't pull admin_events, error_logs, or pg_stat_statements. The Sentry data covered the actual error patterns; the DB-side tables would have given a second signal source. If those tables carry independent errors not seen by Sentry, this run missed them.
  • JAVASCRIPT-NEXTJS-57 (fetchShotDriversByCategory statement timeout) — skipped because PR fix(coachhelm): log best-effort insight-delivery failures as warning #219 is the active fix and was deploying as I wrote this. That PR only demotes severity (warning instead of error). The underlying timeout on the IN-200-round-ids + nested-joins query is still there; if it recurs, the real fix is to reduce SHOT_DRIVERS_ROUNDS_CAP or rewrite as a subquery.

🤖 Generated nightly by Claude Code. Do not auto-merge — human review required.


Generated by Claude Code

Sentry 24h on release 22e1d32 (latest prod, deployed ~22h ago):
  JAVASCRIPT-NEXTJS-50: 46 events / 1 user (escalating), pg_error_code 42501
    "Auto-save update failed: permission denied for table golf_rounds"
  JAVASCRIPT-NEXTJS-4Z: 46 mirrored server-side events (same root)
  JAVASCRIPT-NEXTJS-51: 22 client-side captures (same root, UI wrapper)
  JAVASCRIPT-NEXTJS-58: 2 new events, "Error updating shot:" — same trace
    (3a53170303b74d38b63d28e3f2e96078) as #50, edit-shot path that fans out
    into the same savePartialRound call

Root cause: PR #217 shipped supabase/migrations/20260603040000_grant_update_
golf_rounds_authenticated.sql (column GRANT for player_id, team_id,
qualifier_id, qualifier_round_number), but the migration file was on disk
in main yet never applied to the Supabase production database — this repo
applies migrations manually via the Supabase MCP (no auto-apply step in
build), so the GRANT never landed. The fallback UPDATE path in
savePartialRound (golf.ts:3914, hit when the client doesn't pass
existingRoundId and we look up the in-progress round) kept 42501-ing on
every auto-save tick for the affected user.

Two-part fix that's safe regardless of whether the prior migration ever
gets applied:

1. golf.ts:3911-3921 — strip the four identity columns from the auto-save
   UPDATE payload via object destructure. Identity columns are set on
   INSERT and never change for an in-progress round; re-SETting them on
   each auto-save tick is pointless AND triggers Postgres' per-column
   UPDATE-privilege check on columns the baseline GRANT intentionally
   omits. After the strip, savePartialRound's UPDATE no longer needs
   column grants on identity columns at all. RLS continues to scope rows.

2. supabase/migrations/20260605040000_reaffirm_golf_rounds_update_grants.sql
   — restate the same GRANT under a fresh timestamp so the next
   `supabase db push` / MCP apply picks it up. Idempotent no-op if the
   prior 20260603040000 has since been applied. Aligns DB to code for
   any other UPDATE caller that might still SET these columns.

NEEDS HUMAN STEP: apply the migration to prod Supabase via MCP. The code
change alone fixes the failing path, but the migration brings the DB to
the documented end-state.

Typecheck: pre-existing vitest/globals TS2688 (1 error on main, 1 with
this change — zero new errors). No related vitest unit tests exist for
savePartialRound.

Skipped from the 24h triage:
- JAVASCRIPT-NEXTJS-57 (fetchShotDriversByCategory timeout, 5 events / 0
  users) — actively addressed by PR #219, deploy currently INITIALIZING.
- JAVASCRIPT-NEXTJS-52 (Error deleting shot, 1 event) — single-occurrence
  transient on the same code path; resolved by the same fix above.
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
helmv3 Ready Ready Preview, Comment Jun 5, 2026 4:22am

Request Review

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

njrini99-code has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 41b2ddb9-dae3-4370-9ac0-b02a9542b4bb

📥 Commits

Reviewing files that changed from the base of the PR and between 22e1d32 and 2e5d888.

📒 Files selected for processing (2)
  • src/app/golf/actions/golf.ts
  • supabase/migrations/20260605040000_reaffirm_golf_rounds_update_grants.sql

Summary by CodeRabbit

Bug Fixes

  • Fixed an issue where round updates could accidentally revert completed golf rounds. Improved safeguards ensure round data is now better protected against unintended modifications while allowing necessary updates.

Walkthrough

Database grants and application logic now coordinate to restrict golf_rounds updates. A new migration reapplies column-scoped UPDATE permissions to the authenticated role, and savePartialRound filters the payload to exclude identity columns before updating in-progress rounds.

Changes

Golf Round Update Permissions

Layer / File(s) Summary
Database column-level grant permissions
supabase/migrations/20260605040000_reaffirm_golf_rounds_update_grants.sql
Migration restates idempotent GRANT UPDATE (player_id, team_id, qualifier_id, qualifier_round_number) ON TABLE public.golf_rounds TO authenticated; with context comments referencing prior grant behavior and permission-denied errors.
Application update payload filtering
src/app/golf/actions/golf.ts
savePartialRound derives updatePayload by removing identity columns from roundData before calling golf_rounds.update(...), ensuring only mutable fields are modified while preserving status = 'in_progress' and player ownership guards.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • njrini99-code/helmv3#30: Both PRs coordinate around golf_rounds updates: this PR's savePartialRound removes identity fields from the update payload, and that PR tightens authenticated SQL GRANT UPDATE permissions to the same non-identity allow-list.
  • njrini99-code/helmv3#217: Both PRs target the same Supabase authorization issue by (re)applying column-scoped GRANT UPDATE permissions on public.golf_rounds for identity columns.

Suggested labels

database

🚥 Pre-merge checks | ✅ 4 | ❌ 8

❌ Failed checks (1 warning, 7 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning Title does not follow Conventional Commits format with required scope; 'nightly' is not in the required scopes list (golf, baseball, coachhelm, supabase, ios, ci, design-system, types, deps, docs, ops). Rewrite title to follow Conventional Commits with a required scope, e.g., 'fix(golf): strip identity columns from auto-save UPDATE to resolve 42501 permission errors'.
No Service-Role In Client Bundles ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Rls Coverage On New Tables ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Auth Check In Server Actions ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Sport-Prefixed Table Names ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No Destructive Writes ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No Edits To Historical Migrations ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Conventional Commits ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed Description is directly related to the changeset; it documents the root cause (unapplied migration 20260603040000 blocking identity column UPDATEs), the two-part fix (code change in golf.ts, new migration), and deployment instructions.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nightly-health-check/2026-06-05

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.43.0)
src/app/golf/actions/golf.ts

Error: Cannot parse rule /ast-grep-rules/../git/.coderabbit/ast-grep/no-explicit-any.yml
Help: The file is not a valid ast-grep rule. Please refer to doc and fix the error.
See also: https://ast-grep.github.io/guide/rule-config.html

✖ Caused by
╰▻ Fail to parse yaml as Rule.
╰▻ rule is not configured correctly.
╰▻ Rule contains invalid pattern matcher.
╰▻ Multiple AST nodes are detected. Please check the pattern source as any.

supabase/migrations/20260605040000_reaffirm_golf_rounds_update_grants.sql

Error: Cannot parse rule /ast-grep-rules/../git/.coderabbit/ast-grep/no-explicit-any.yml
Help: The file is not a valid ast-grep rule. Please refer to doc and fix the error.
See also: https://ast-grep.github.io/guide/rule-config.html

✖ Caused by
╰▻ Fail to parse yaml as Rule.
╰▻ rule is not configured correctly.
╰▻ Rule contains invalid pattern matcher.
╰▻ Multiple AST nodes are detected. Please check the pattern source as any.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@njrini99-code

Copy link
Copy Markdown
Owner Author

Folded into #304 (feat/coachhelm-stats-roundup) — merged clean, combined gates green. Branch intact + reopenable.

@njrini99-code
njrini99-code deleted the nightly-health-check/2026-06-05 branch June 29, 2026 12:17
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.

2 participants