Fix verification API JSON parsing errors blocking task completion#16
Draft
Fix verification API JSON parsing errors blocking task completion#16
Conversation
…hecking Co-authored-by: codenimar <119526795+codenimar@users.noreply.github.com>
…ge case test Co-authored-by: codenimar <119526795+codenimar@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix verification buttons blocking task completion
Fix verification API JSON parsing errors blocking task completion
Jan 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Verification buttons threw
Unexpected token '<', "<!doctype "...errors when API endpoints returned HTML (404/error pages), blocking users from earning points.Changes
Content-Type validation - Check response headers before parsing:
Error handling hierarchy - Distinguish technical errors from user failures:
SyntaxErrorfirst (beforeisUserVerificationFailureflag) - handles edge case where non-ok response has malformed JSONTest coverage - 14 tests covering HTML responses, malformed JSON, network errors, edge cases
Behavior
Maintains backwards compatibility for deployments without verification APIs.
Original prompt
Critical Bug: Verification Buttons Block Task Completion
Error Message:
Problem
Users cannot complete tasks because the verification system is throwing errors instead of gracefully falling back. The error occurs because:
src/utils/api.tscallsawait response.json()without checking if the response is actually JSONRoot Cause Analysis
The code assumes the response is always JSON, but when serverless functions aren't deployed or return 404s, it breaks.
Required Fix
In
src/utils/api.ts- UpdateXPostAPI.verifyActionmethod (lines 607-702)Replace the entire fetch/parse logic with proper error handling:
Why This Fix Works
Expected Behavior After Fix
Testing Checklist
After...
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.