Skip to content

fix(api): propagate database errors correctly in local-coding stats endpoint#1793

Open
ArshVermaGit wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
ArshVermaGit:main_5
Open

fix(api): propagate database errors correctly in local-coding stats endpoint#1793
ArshVermaGit wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
ArshVermaGit:main_5

Conversation

@ArshVermaGit
Copy link
Copy Markdown
Contributor

Description

This PR addresses a silent failure issue in the backend where critical database connection or query errors were being intentionally swallowed by the API.

Previously, the /api/local-coding/stats route caught database query failures (e.g., if the Supabase instance was down or unreachable) and "gracefully degraded" by returning an empty, mock data object alongside a 200 OK status. This masked underlying infrastructure issues, broke frontend error handling (since the fetch API assumed success), and made debugging significantly more difficult.

Resolved Issue

Resolves #1792

Changes Made

  • Error Propagation: Removed the fallback mechanism in src/app/api/local-coding/stats/route.ts. The endpoint now correctly catches database errors, logs them to the server console, and halts execution by returning a standard 500 Internal Server Error status with an appropriate error message.

Impact

  • Observability: Backend database failures are now immediately visible to the frontend, enabling proper fallback states, retry logic, or user-facing error messages instead of displaying mysteriously empty charts.

Testing

  • Ran the unit test suite (npm run test test/local-coding-stats.test.ts).
  • Verified that the test asserting the endpoint "returns 500 when Supabase fails instead of hiding the error as empty stats" now completely passes.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 31, 2026

@ArshVermaGit is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix labels May 31, 2026
@github-actions
Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Copy link
Copy Markdown
Contributor Author

@ArshVermaGit ArshVermaGit left a comment

Choose a reason for hiding this comment

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

Hi @Priyanshu-byte-coder ! Issue #1792 has been resolved. Please review the PR and merge it under GSSoC. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: API routes silently masking database errors with 200 OK responses

1 participant