Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message if JSON response is empty #296

Open
WolfgangFahl opened this issue Apr 21, 2023 · 2 comments
Open

Improve error message if JSON response is empty #296

WolfgangFahl opened this issue Apr 21, 2023 · 2 comments

Comments

@WolfgangFahl
Copy link

WolfgangFahl commented Apr 21, 2023

When debugging https://phabricator.wikimedia.org/T335073 see https://stackoverflow.com/questions/76072671/guzzle-update-brakes-mediawiki-1-39-3-lts-what-are-the-reasons-and-workarounds

i got:

Did not get a valid JSON response from the server. Check that you used the correct hostname. If you did, the server might be wrongly configured or experiencing temporary problems.

which i consider quite misleading when the JSON response is empty.

IMHO there should be a hint in this case that JSON is empty (which is a subset of not valid).The situation needs to be replicated manually and then mediawiki debugging needs to be switched on. In my case the culprit was a:

PHP Fatal error: Declaration of MWCallbackStream::write($string) must be compatible with Psr\Http\Message\StreamInterface::write(string $string): int in /home/user/public_html/muizenmesh.co.za/wiki/includes/http/MWCallbackStream.php  on line 49

which is just an annoying dependency hell situation.

@AdamWill
Copy link
Member

well, "the server might be wrongly configured or experiencing temporary problems" points you pretty clearly in the direction of the server. I'm not sure I see why we should consider the JSON being empty a particularly special case; any time the response is invalid JSON in any way, that's kinda out of the realm of something mwclient can do anything about, and needs to be resolved somewhere else. We could maybe strengthen the "the server might be wrongly configured" part to more specifically say "go figure out what's wrong with the server"? But I'm not sure a different message for the response being empty vs. it being invalid in any other way makes sense.

@WolfgangFahl
Copy link
Author

It get's worse:
a "JSON result" might be:

str: {"edit":{"result":"Success","pageid":1,"title":"Main Page","contentmodel":"wikitext","nochange":"","watched":""}}<br />
<b>Deprecated</b>:  Use of InternalParseBeforeSanitize hook (used in VariablesHooks::onInternalParseBeforeSanitize) was deprecated in MediaWiki 1.35. [Called from MediaWiki\HookContainer\HookContainer::run in /var/www/html/includes/HookContainer/HookContainer.php at line 137] in <b>/var/www/html/includes/debug/MWDebug.php</b> on line <b>381</b><br />

which will also make mwclient choke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants