Skip to content

fix(mw): send every API call through one request path - #52

Merged
CameronBrooks11 merged 1 commit into
mainfrom
fix/mw-request-path
Nov 13, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
fix/mw-request-path

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

Every API call in internal/mw now goes through Client.call, which builds the GET or POST request, checks the HTTP status, handles MediaWiki's error envelope and decodes the response. It replaces 8 hand-written copies of those steps, and fetchBatchOnce and RevisionText now share one revisionsResponse type.

The bug: token, Login and Edit skipped the status check, so a wiki answering 503 with an HTML page failed with invalid character '<' looking for beginning of value. TestCallsReportHTTPStatus points every public call at such a server and requires the status in the error. With the status check disabled in call, it fails for all 7 calls.

An edit the wiki refuses now reads mediawiki api error <code>: <info> instead of edit error <code>: <info>. That's in the changelog.

Net −70 lines (148 added, 218 removed, tests included).

Closes #45

token, Login and Edit decoded the response without checking the HTTP
status, so a wiki answering 503 with an HTML page gave "invalid
character '<'" instead of the status. Each of the 8 calls repeated the
request, status, decode and error-envelope steps, and Edit and
fetchBatchOnce redeclared shapes that already existed.

All calls now go through Client.call, which checks the status and the
error envelope once. Edit errors use the shared apiError format.

Closes #45
@CameronBrooks11
CameronBrooks11 merged commit 6c6317b into main Nov 13, 2026
9 checks passed
@CameronBrooks11
CameronBrooks11 deleted the fix/mw-request-path branch November 13, 2026 17:08
CameronBrooks11 added a commit that referenced this pull request Nov 13, 2026
Prepares v0.5.1: the version constant becomes 0.5.1, and the CHANGELOG's
Unreleased section becomes 0.5.1. User-facing changes since v0.5.0: #52
(HTTP status on login and edit errors, #45), #53 (conflict check reads
the revision id only, #46), #61 (login failure and count wording, #56),
#62 (push read-back warning, #58). The rest are refactors with no change
in behaviour: #54, #55, #57, #59, #60. The tag is pushed after this
merges.
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.

mw: send every API call through one request path

1 participant