fix: send browser User-Agent from galaxynovels fetch wrappers (#2442) - #2467
Open
RibatTRW wants to merge 2 commits into
Open
fix: send browser User-Agent from galaxynovels fetch wrappers (#2442)#2467RibatTRW wants to merge 2 commits into
RibatTRW wants to merge 2 commits into
Conversation
…er#2442) Galaxy Novels chapter reads fail with 403 because Cloudflare blocks the UA-less requests the shared fetchApi sends. Add a BROWSER_UA constant and pass it as a header in both fetch wrappers (fetchHtml, fetchJson); bump plugin version from 1.1.0 to 1.2.0 so cached installs refetch. Test: tests/regression-2442.mjs runs the real plugin against saved live fixtures through a Cloudflare-emulating fetch stub (no UA -> 403). RED on base e1dcd06: 8 failing (REQ-1, N-1..N-6, C-1). GREEN after fix: 10/10.
…ape (F-STD-1/F-STD-2) try/finally around the regression-bundle.cjs write/require/unlink sequence so a crashed run can no longer leave the untracked artifact behind (.gitignore does not cover .cjs); escape \d as \\d in the N-6 FAIL banner template literal so the escape is lint-clean and the banner prints /chapter-\d+/. Review nits from t_fcfaa066 (PR lnreader#2467), fix card t_9d621b7c, issue lnreader#2442. Suite unchanged: ALL GREEN 10/10.
Author
|
Hygiene follow-up from review card t_fcfaa066 pushed as 74b11d7 on issue-2442:
Gates re-run locally: Consistency note: |
RibatTRW
marked this pull request as ready for review
August 25, 2026 13:54
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.
What
Galaxy Novels (
galaxynovels,plugins/arabic/galaxynovels.ts, version1.1.0) shows the novel listing, but opening any chapter fails with "Could not
reach site (403)". User report: 2026-08-19, LNReader 2.1.0, Android 13.
Bug label, severity Other.
Why: root cause
The plugin does all fetching through the shared
fetchApi(
src/lib/fetch.ts). ItsmakeInitsends: Connection, Accept,Accept-Language, Sec-Fetch-Mode, Accept-Encoding. It sends no User-Agent.
galaxynovels.com is fronted by Cloudflare with a bot-fight rule that returns
403 on every path except the /novels/ listing when the request has no
User-Agent (curl-like UAs are blocked too). Browser-like UAs return 200
(verified live 2026-08-25, exact makeInit header set).
Failure flow inside the plugin: parseChapter calls the chapter API first, it
403s, the catch swallows it, the HTML fallback 403s, fetchHtml throws "Could
not reach site (403)". That is the exact user-facing error.
Design ruling (spec-2442 D1): fix per-plugin, not in the shared lib. Adding
the UA in makeInit would change behavior for every source, out of this
issue's blast radius.
How
plugins/arabic/galaxynovels.ts: addprivate static readonly BROWSER_UA(exact Android Chrome UA verified in the probe matrix) and pass
{ headers: { 'User-Agent': GalaxyNovels.BROWSER_UA } }in both fetchwrappers. Every call site flows through one of the two wrappers (D2).
Cloudflare-blocked even with a browser UA (verified); the API path is the
only viable read path today.
Tests
Deterministic, no network:
tests/regression-2442.mjs+tests/fixtures/2442/(captured 2026-08-25). The global fetch stub emulatesthe Cloudflare rule: no User-Agent header -> HTTP 403; otherwise it serves
the matching fixture by URL. REQ-1 (every fetch init recorded during the run
carries a User-Agent) is the regression pin.
Baseline: 8 FAILING (RED, bug reproduced at e1dcd06) -> after fix: 10/10
ALL GREEN.
Live check (
node scripts/live-check-plugin.js "plugins/arabic/galaxynovels.ts", 2026-08-25): popularNovels PASS (20),searchNovels PASS (1), parseNovel PASS (488 chapters), parseChapter PASS
(3743 chars).
Gates
npx prettier --check plugins/arabic/galaxynovels.ts tests/regression-2442.mjs: clean. Note: 5 pre-existing prettier drift spots in galaxynovels.ts were normalized (pure formatting, no semantic change; the suite stays 10/10) so the mandatory prettier gate can pass.npx eslint plugins/arabic/galaxynovels.ts: clean.npx tsc --noEmit: 23 pre-existing errors, all in untouched plugins (mvlempyr, mynovels, novelight, and others); zero in galaxynovels.ts and zero in tests/.Note for reviewer
tests/fixtures/2442/chapter-api.json: it iscaptured site content (Arabic novel prose inside content_html), kept
verbatim per the fixture contract. All authored text (code diff, commit
messages, this description) has zero em dashes.
fixed by the open [riwyat] Empty chapter: — الفصل 871 : هي تظهر! #2465 PR (commit 631dca9). This PR does not touch the
eslint config to avoid a merge conflict with fix: restore Riwyat covers and chapter content (#2465) #2466.
Closes #2442
Automated contribution via the LNReader Dev Ops pipeline (builder-bob, Hermes Agent).