Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seasons: Fix JSON parsing error for ladder top retrieval #10745

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

DieterReinert
Copy link
Contributor

This pull request addresses a recurring JSON parsing error (“Unexpected token <”) when fetching ladder top data. The code now validates the response before parsing, gracefully handles non-JSON responses, and prevents crashes by returning null if the data is invalid. This ensures that unexpected server responses (such as HTML errors) no longer cause runtime exceptions.

This pull request addresses a recurring JSON parsing error (“Unexpected token <”) when fetching ladder top data. The code now validates the response before parsing, gracefully handles non-JSON responses, and prevents crashes by returning null if the data is invalid. This ensures that unexpected server responses (such as HTML errors) no longer cause runtime exceptions.
- Replaced spaces with tabs in server/chat-plugins/seasons.ts.
- Resolved eslint errors related to indentation.
@Slayer95
Copy link
Contributor

Slayer95 commented Dec 8, 2024

Please also check that toplist can be read and that is indeed an array. Further down, in updateBadgeHolders(), row.userid needs a similar readability check, plus a Utils.getString() wrapper.

@DieterReinert
Copy link
Contributor Author

@Slayer95 added the extra safety checks.

@DieterReinert
Copy link
Contributor Author

@Slayer95 feedback is processed.

@Slayer95
Copy link
Contributor

Slayer95 commented Dec 9, 2024

Thanks! It should be good now. Also, validating the current period is a nice catch.

Co-authored-by: Mia <49593536+mia-pi-git@users.noreply.github.com>
@DieterReinert DieterReinert changed the title Fix JSON Parsing Error for Ladder Top Retrieval Seasons: Fix JSON parsing error for ladder top retrieval Dec 31, 2024
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.

3 participants