macbre/nodemw

[0.11.0 Regression] Edits fail but claim success (err = null)

Closed this issue · 3 comments

In most cases, such as http-level errors, json-parse errors, or standard MediaWiki API errors that use data.error = { code, info }, nodemw detects it at the call() layer in doRequest, and will invoke the callback with just an Error object.

For doEdit(), this isn't the case for legacy behaviour where action=edit responds without data.error but still have data.edit.result = "Failure". This is still the case for errors from AbuseFilter, ConfirmEdit, SpamBlacklist, and possibly others.

In those cases, additional information is in the other properties of the data.edit object. Their format is non-standard, so we probably still can't provide anything beyond "Edit failed". However, I liked it before #121 because previously it would pass an Error object saying "Edit failed null". With 0.11.0 I'm just getting null, which means my callbacks assume success!

The following would fix the regression, and also fulfil my request of wanting access to response data - which I assumed #121 would do:

- callback(err);
+ callback(err || data);

@Krinkle, definitely makes sense. I'll fix that. Thanks!

Ok, let's test it by adding http://clicky.pk/foo to my personal sandbox user page (this triggers spam blacklist protection).

With a fix suggested by @Krinkle nodemw now reports the following:

info:    Sandbox edit failed: {"captcha":{"type":"image","mime":"image/png","id":"1624961834","url":"/w/index.php?title=Special:Captcha/image&wpCaptchaId=1624961834"},"result":"Failure"}