Skip to content

fix(mw): follow continuation when a page batch is truncated - #19

Merged
CameronBrooks11 merged 1 commit into
mainfrom
fix/fetch-continue
Oct 31, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
fix/fetch-continue

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

What

MediaWiki caps an API response at 8 MiB. When a batch of 50 pages goes over it,
the response omits some pages' revisions and returns continue. FetchPages
ignored that, so those pages came back as "page does not exist", and pull
still exited 0. No local file was overwritten: missing pages are skipped.

fetchBatch now re-requests with the continuation until there is none. A
continued request that brings no new page text is an error, not a loop.

Evidence

The 50 Appropedia pages from list=allpages&apminsize=200000:

  • One raw batch request: 30 pages with content, 20 without, plus
    continue: {"rvcontinue": …} and "This result was truncated because it would
    otherwise be larger than the limit of 8,388,608 bytes."
  • wikisync pull with the 0.2.0 release binary: exit 0, 30 pulled, 20
    "does not exist".
  • wikisync pull with this branch: exit 0, 50 pulled, 0 "does not exist".

Tests

  • TestFetchPagesFollowsTruncatedBatch: the first response leaves out two
    pages and continues; they must arrive on the second request. Fails on main
    (Big B and Big C reported missing, 1 request).
  • TestFetchPagesStopsOnStalledContinuation: a continuation that never
    delivers the page must return an error within two requests.
  • Separately breaking each part (continuation ignored, not sent, no stall
    guard, a later round's text-less page overwriting the earlier text) fails
    its target test.

MediaWiki caps an API response at 8 MiB. When a batch of 50 pages goes
over it, the response leaves some pages' revisions out and returns a
"continue" value. FetchPages ignored it, so those pages were reported
as "page does not exist" and the pull still exited 0.

On Appropedia, the 50 pages from list=allpages&apminsize=200000: one
request returned text for 30 of them, plus the truncation warning.
wikisync 0.2.0 pulled 30 and called 20 missing. With this change it
pulls all 50.

fetchBatch now re-requests with the continuation until it runs out. A
continued request that brings no new page text is an error rather
than a loop.
@CameronBrooks11
CameronBrooks11 merged commit cdbe23e into main Oct 31, 2026
6 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/fetch-continue branch October 31, 2026 01:02
@CameronBrooks11 CameronBrooks11 mentioned this pull request Oct 31, 2026
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.

1 participant