Skip to content

fix: prevent silent goal erasure when loadGoals fails (Issue #2)#2287

Open
just-tanvi wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
just-tanvi:fix/issue-2-loadgoals
Open

fix: prevent silent goal erasure when loadGoals fails (Issue #2)#2287
just-tanvi wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
just-tanvi:fix/issue-2-loadgoals

Conversation

@just-tanvi

Copy link
Copy Markdown

Description

This PR fixes a critical UX bug where the Goals widget would silently clear all visible goals and revert to the empty state if the /api/goals endpoint returned a non-OK response (e.g. 401 Unauthorized, 500 Internal Server Error).

Previously, loadGoals called .json() without verifying response.ok. Since error responses return an error payload (without a goals array), data.goals would be undefined. The widget defaulted this to an empty array and called setGoals([]), effectively wiping the user's view without giving them any feedback that a network/server issue had occurred.

Changes Made

  • Added a !response.ok guard in loadGoals (inside src/components/GoalTracker.tsx) that immediately throws an error containing the HTTP status code.
  • Updated the .catch(() => {}) blocks at the three affected call sites to explicitly catch these network errors and call setSyncError(...) with an appropriate, user-facing error message.
  • Adjusted test assertions to ensure tests accurately reflect the widget's gracefully handled error states.

Testing

  • Verified that all unit tests for the GoalTracker component (npx vitest run test/GoalTracker.test.ts) pass successfully.
  • Verified that a failing loadGoals call now preserves the current goals in the UI and correctly bubbles the error up to the UI banner.

closes #2285

@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

@just-tanvi 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 type:testing GSSoC type bonus: tests (+10 pts) labels Jun 10, 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

@github-actions github-actions Bot added type:feature GSSoC type bonus: new feature type:design GSSoC type bonus: UI/design (+10 pts) type:performance GSSoC type bonus: performance (+15 pts) labels Jun 10, 2026
@just-tanvi

Copy link
Copy Markdown
Author

@Priyanshu-byte-coder I will try to fix the 2 failing checks in the pr but it might take me some time, Thankyou for understanding !

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 type:design GSSoC type bonus: UI/design (+10 pts) type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] loadGoals silently replaces all visible goals with an empty list when the API returns an error response

1 participant