Skip to content

fix(coachhelm): log best-effort insight-delivery failures as warning - #219

Closed
njrini99-code wants to merge 1 commit into
mainfrom
claude/coachhelm-besteffort-warning-severity
Closed

fix(coachhelm): log best-effort insight-delivery failures as warning#219
njrini99-code wants to merge 1 commit into
mainfrom
claude/coachhelm-besteffort-warning-severity

Conversation

@njrini99-code

Copy link
Copy Markdown
Owner

Fixes Sentry JAVASCRIPT-NEXTJS-57

Issue: fetchShotDriversByCategory failed (continuing without shot drivers): canceling statement due to statement timeout on GET /golf/dashboard/coachhelm. 3 occurrences, 0 users impacted.

Diagnosis

fetchShotDriversByCategory, fetchSgTrendsByCategory, and the SG fetch in assembleForPlayer (src/app/golf/actions/insight-delivery.ts) are all best-effort enrichments — the CoachHelm themes page renders correctly without them (the helpers catch, return undefined, and the assembler omits the data). The shot-drivers query is heavy (up to 5000 shots across up to 200 rounds with two nested JSON embeds) and occasionally trips the Postgres statement_timeout under load.

The only thing actually wrong: these handled, gracefully-degraded failures were logged at error severity, so they paged like real crashes despite zero user impact — contradicting the helpers' own contract ("NEVER errors the page").

Not an indexing problem — verified against prod: golf_shots(round_id) is indexed (plus a covering index), and putt_details(shot_id) / approach_miss_details(shot_id) are indexed/unique.

Change

Pass 'warning' severity to the three best-effort logServerError calls. The logger captures info/warning as non-exception messages (see server-error-logger.ts), so these become low-severity signals instead of paging error events — the same convention PR #216 used for handled control-flow.

No behavior change to the page — purely a logging-severity correction.

Verification

  • npm run typecheck — clean
  • npx eslint src/app/golf/actions/insight-delivery.ts — clean

Deferred (optional, not in this PR)

Lowering SHOT_DRIVERS_ROUNDS_CAP (200 → ~50) would reduce how often the query times out at all. Left out per scope decision; can follow up if the warnings stay noisy.

https://claude.ai/code/session_01NSJu2jvRqKxgk7vhvKZXeq


Generated by Claude Code

… not error

fetchShotDriversByCategory / fetchSgTrendsByCategory / the SG fetch in
assembleForPlayer are all best-effort enrichments — the CoachHelm themes
page renders correctly without them. A handled failure (e.g. a Postgres
statement timeout on the heavy golf_shots shot-drivers query) was logged at
`error` severity, so it paged like a real crash (Sentry JAVASCRIPT-NEXTJS-57)
despite 0 user impact.

Pass 'warning' severity so these handled, gracefully-degraded conditions are
captured as non-exception messages instead of error-level events — matching
the logger's existing control-flow-signal convention. No behavior change to
the page; indexes on golf_shots(round_id) and the child shot_id columns are
already healthy, so this is purely a logging-severity correction.

https://claude.ai/code/session_01NSJu2jvRqKxgk7vhvKZXeq
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
helmv3 Error Error Jun 5, 2026 4:03pm

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 4, 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: 4ef62c1c-8b10-4371-a132-c78dc7e432a7

📥 Commits

Reviewing files that changed from the base of the PR and between 22e1d32 and 51dbc76.

📒 Files selected for processing (1)
  • src/app/golf/actions/insight-delivery.ts

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for data enrichment operations. The system now gracefully treats certain recoverable failures as non-fatal warnings, allowing analytical operations to continue functioning instead of failing completely when encountering transient issues.

Walkthrough

This PR updates three best-effort enrichment failure paths in src/app/golf/actions/insight-delivery.ts to explicitly mark handled failures as non-fatal warnings. fetchShotDriversByCategory, fetchSgTrendsByCategory, and assembleForPlayer SG fetch now pass 'warning' severity to logServerError, with comments updated to reflect graceful degradation rather than error behavior.

Changes

Non-fatal warning logging for enrichment failures

Layer / File(s) Summary
Enrichment error handling as warnings
src/app/golf/actions/insight-delivery.ts
Lines 646–652, 697–702, 766–771: fetchShotDriversByCategory, fetchSgTrendsByCategory, and assembleForPlayer SG fetch now explicitly log handled failures with non-fatal 'warning' severity via logServerError. Inline comments updated to indicate graceful degradation (page/themes/scaffold continue without enrichment data).

🎯 1 (Trivial) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Title check ✅ Passed Title follows Conventional Commits with 'fix' type and 'coachhelm' scope, which are both required. It clearly describes the change: adjusting logging severity for best-effort failures.
Description check ✅ Passed Description comprehensively covers the change: Sentry issue reference, problem diagnosis, technical rationale, verification steps, and scope boundaries. Directly addresses the changeset in src/app/golf/actions/insight-delivery.ts.
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.
No Service-Role In Client Bundles ✅ Passed PR modifies src/app/golf/actions/insight-delivery.ts only, which uses createClient from @/lib/supabase/server (anon key). No SERVICE_ROLE_KEY references.
Rls Coverage On New Tables ✅ Passed PR adds no database migrations; only modifies TypeScript application code (src/app/golf/actions/insight-delivery.ts). RLS check not applicable.
Auth Check In Server Actions ✅ Passed All 6 exported async functions in src/app/golf/actions/insight-delivery.ts call supabase.auth.getUser() before database operations: lines 188, 278, 392, 487, 847, 878.
Sport-Prefixed Table Names ✅ Passed All Supabase queries use sport-prefixed tables: golf_coach_insights, golf_rounds, golf_shots. No non-prefixed tables (coaches, players, teams, rounds, events) are queried.
No Destructive Writes ✅ Passed PR contains no DELETE or INSERT operations; insight-delivery.ts has only .select() reads. Check for destructive DELETE+INSERT patterns is N/A.
No Edits To Historical Migrations ✅ Passed PR adds new migration files but does not modify existing ones. Check requires failing on modifications; adding new files does not violate the policy.
Conventional Commits ✅ Passed PR title "fix(coachhelm): log best-effort insight-delivery failures as warning" matches Conventional Commits format with valid type (fix), scope (coachhelm), and message.

✏️ 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 claude/coachhelm-besteffort-warning-severity

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/insight-delivery.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.


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 claude/coachhelm-besteffort-warning-severity 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