Repository navigation
fix(mw): send every API call through one request path - #52
Merged
Merged
Conversation
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
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.
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.
Every API call in
internal/mwnow goes throughClient.call, which builds the GET or POST request, checks the HTTP status, handles MediaWiki'serrorenvelope and decodes the response. It replaces 8 hand-written copies of those steps, andfetchBatchOnceandRevisionTextnow share onerevisionsResponsetype.The bug:
token,LoginandEditskipped the status check, so a wiki answering 503 with an HTML page failed withinvalid character '<' looking for beginning of value.TestCallsReportHTTPStatuspoints every public call at such a server and requires the status in the error. With the status check disabled incall, it fails for all 7 calls.An edit the wiki refuses now reads
mediawiki api error <code>: <info>instead ofedit error <code>: <info>. That's in the changelog.Net −70 lines (148 added, 218 removed, tests included).
Closes #45