Skip to content

fix: report connection errors instead of "No results found!" - #1880

Open
DavidsonRafaelK wants to merge 1 commit into
pystardust:masterfrom
DavidsonRafaelK:fix/connection-error-message
Open

fix: report connection errors instead of "No results found!"#1880
DavidsonRafaelK wants to merge 1 commit into
pystardust:masterfrom
DavidsonRafaelK:fix/connection-error-message

Conversation

@DavidsonRafaelK

Copy link
Copy Markdown

Closes #1879.

Problem

When anidb_curl fails at the network level the body is empty, so the Just a moment check in anidb_search never fires and the empty result falls through to die "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 die only exits the subshell. The message is printed, the parent keeps going with an empty variable, and reaches the next die. A cloudflare block today prints both lines:

$ sh demo.sh          # die inside $( ), reduced to the essentials
Blocked by cloudflare. Try installing curl-impersonate
No results found!

Change

  • Empty-response guard in anidb_search and anidb_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 1 at the four call sites, so the message the subshell printed actually stops the run instead of being followed by a second, contradictory one.
  • Version bumped to 5.0.4.

anidb_desc is deliberately untouched: its metadata is optional and the caller already writes anidb_desc "$anime_id" || true. process_hist_entry is untouched too, since it runs backgrounded per history entry.

Before / after

Same binary, base_api pointed at a blackhole address (198.51.100.1) to force the timeout path:

=== 5.0.3 ===
Checking dependencies...
No results found!

=== patched ===
Checking dependencies...
Connection error: no response from https://198.51.100.1

Checks

  • shellcheck -s sh -o all -e 2250 ani-cli — clean
  • shfmt -i 4 -ci -d ani-cli — clean
  • test -x ani-cli — ok
  • no awk, no wget added
  • version_number bumped, so the version-bump job sees it
  • README needs no change: no flags, no behaviour outside the error path

Commit is co-authored by the agent that helped write it, as requested in #1879.

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>
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.

Network failures are reported as "No results found!", hiding connection errors

1 participant