fix(wallpapers): fail gracefully when the osu! API is unreachable - #3599
Open
ksh2177 wants to merge 1 commit into
Open
fix(wallpapers): fail gracefully when the osu! API is unreachable#3599ksh2177 wants to merge 1 commit into
ksh2177 wants to merge 1 commit into
Conversation
The seasonal-backgrounds endpoint sits behind Cloudflare, which currently answers with an HTML challenge page instead of JSON (end-4#3590). The script had no guards, so a failure cascaded: jq parse error, division by zero, curl invoked with an empty URL, then matugen and switchwall erroring on a nonexistent image file. The wall itself cannot be fixed client-side (no script can solve a JS challenge - even a same-origin fetch from a logged-in browser session gets the challenge page). This makes the failure mode sane meanwhile: one notification and a clean exit, both for the API call and for the image download.
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.
Describe your changes
Related to #3590. The
seasonal-backgroundsendpoint currently answers with a Cloudflare HTML challenge page instead of JSON. The random osu! script had no guards, so a failure cascaded into a mess: jq parse error → division by zero →curlinvoked with an empty URL → matugen and switchwall erroring on a nonexistent image file, leaving the wallpaper state broken.The wall itself cannot be fixed client-side — no script can solve a JS challenge (I verified that even a same-origin
fetchfrom a logged-in browser session on osu.ppy.sh gets the challenge page for this endpoint). What can be fixed is the failure mode: this PR makes it one clear notification and a clean exit, both for the API call and for the image download. It also sends a User-Agent andAccept: application/json, which costs nothing and helps whenever the protection relaxes.Tested on Arch + Hyprland: with the endpoint walled, one notification, exit 1, no cascade; the rest of the script is untouched for the day the API answers again.
Is it ready? Questions/feedback needed?
Ready. If you'd rather swap the source for another seasonal wallpaper API instead, happy to rework — but graceful failure seems worth having regardless of the source.