fix: report connection errors instead of "No results found!" - #1880
Open
DavidsonRafaelK wants to merge 1 commit into
Open
fix: report connection errors instead of "No results found!"#1880DavidsonRafaelK wants to merge 1 commit into
DavidsonRafaelK wants to merge 1 commit into
Conversation
When a request to anidb.app fails at the network level the response body is empty, so the "Just a moment" cloudflare check in anidb_search never fires and the empty result falls through to die "No results found!". A site outage, a dropped connection and a genuinely unknown anime all produced the same message. Guard the two scrapers whose emptiness is never legitimate, anidb_search and anidb_episodes, with an explicit empty-response check that names the host instead. The callers needed the || exit 1 as well. Both run the scraper inside a command substitution, so die only exits the subshell: the message was printed and then the parent carried on with an empty variable, which is why a cloudflare block already printed "Blocked by cloudflare." followed by "No results found!". Propagating the status stops that. anidb_desc is left alone, since its metadata is optional and its caller deliberately ignores failures, as is process_hist_entry, which runs in the background per history entry. Closes pystardust#1879 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Closes #1879.
Problem
When
anidb_curlfails at the network level the body is empty, so theJust a momentcheck inanidb_searchnever fires and the empty result falls through todie "No results found!". A site outage, a dropped connection, a DNS failure and a genuinely unknown anime all produced the same message. That is what the current anidb.app outage in #1877 looks like from the user side.There is a second half to it. Both scrapers are called inside a command substitution:
anime_list=$(anidb_search "$query")so
dieonly exits the subshell. The message is printed, the parent keeps going with an empty variable, and reaches the nextdie. A cloudflare block today prints both lines:Change
anidb_searchandanidb_episodes, the two scrapers where an empty body is never a legitimate answer. It names the host:Connection error: no response from https://anidb.app.|| exit 1at the four call sites, so the message the subshell printed actually stops the run instead of being followed by a second, contradictory one.anidb_descis deliberately untouched: its metadata is optional and the caller already writesanidb_desc "$anime_id" || true.process_hist_entryis untouched too, since it runs backgrounded per history entry.Before / after
Same binary,
base_apipointed at a blackhole address (198.51.100.1) to force the timeout path:Checks
shellcheck -s sh -o all -e 2250 ani-cli— cleanshfmt -i 4 -ci -d ani-cli— cleantest -x ani-cli— okawk, nowgetaddedversion_numberbumped, so the version-bump job sees itCommit is co-authored by the agent that helped write it, as requested in #1879.