Re: [Mediawiki-api-announce] BREAKING CHANGE: Parameter validation error codes

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [Mediawiki-api-announce] BREAKING CHANGE: Parameter validation error codes

Chen Xinyan
Just out of curiosity, is there any recommended way to parse out "which" parameter goes wrong. For example, we have "unknown_action" before. Now it gets merged into "badvalue", and the response looks like this:

{
    "error": {
        "code": "badvalue",
        "info": "Unrecognized value for parameter \"action\": test.",
        "*": "See https://test2.wikipedia.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes."
    },
    "servedby": "mw1361"
}

Do I have to parse into .error.info content to know the parameter name? Would its content change (such as localized) under certain situation?

Thanks,
Xinyan

-----Original Message-----
From: Mediawiki-api <[hidden email]> On Behalf Of [hidden email]
Sent: Wednesday, February 5, 2020 8:00 PM
To: [hidden email]
Subject: Mediawiki-api Digest, Vol 150, Issue 4

Send Mediawiki-api mailing list submissions to
        [hidden email]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
or, via email, send a message with subject or body 'help' to
        [hidden email]

You can reach the person managing the list at
        [hidden email]

When replying, please edit your Subject line so it is more specific than "Re: Contents of Mediawiki-api digest..."


Today's Topics:

   1. [Mediawiki-api-announce] BREAKING CHANGE: Parameter
      validation error codes (Brad Jorsch (Anomie))
   2. [Mediawiki-api-announce] BREAKING CHANGE: Stricter validation
      of integer-type parameters (Brad Jorsch (Anomie))
   3. Re: [Mediawiki-api-announce] BREAKING CHANGE: Parameter
      validation error codes (Furkan Gözükara)


----------------------------------------------------------------------

Message: 1
Date: Tue, 4 Feb 2020 13:24:32 -0500
From: "Brad Jorsch (Anomie)" <[hidden email]>
To: [hidden email]
Subject: [Mediawiki-api] [Mediawiki-api-announce] BREAKING CHANGE:
        Parameter validation error codes
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="utf-8"

The error codes that may be changing are some of those representing invalid values for API parameters. Notably, the following will change:

   - "noX", indicating that a required parameter was not specified, becomes
   "missingparam".
   - "unknown_X", indicating that an unrecognized value was specified for
   an enumerated-value parameter, becomes "badvalue".
   - "too-many-X", indicating that too many values were supplied to a
   multi-valued parameter, becomes "toomanyvalues".
   - "baduser_X", "badtimestamp_X", and so on become "baduser",
   "badtimestamp", and so on.

Note this is not a comprehensive list, other codes may be changing as well.

These changes make the error codes more predictable, at the expense of not indicating in the code which parameter specifically triggered the error. If you have a use case where knowing which parameter triggered the error is needed, please let us know (by replying to this message or by filing a request in Phabricator) and we'll add the necessary error metadata.

The human-readable text is also changing for some of these errors (with or without error code changes), and for a few the error metadata may be changing (e.g. "botMax" changes to "highmax" for limit-type warnings in non-back-compat error formats).

This change will most likely go out to Wikimedia wikis with 1.35.0-wmf.19.
See https://www.mediawiki.org/wiki/MediaWiki_1.35/Roadmap for a schedule.

--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20200204/54b4bc1e/attachment-0001.html>
-------------- next part --------------
_______________________________________________
Mediawiki-api-announce mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce

------------------------------

Message: 2
Date: Tue, 4 Feb 2020 13:24:34 -0500
From: "Brad Jorsch (Anomie)" <[hidden email]>
To: [hidden email]
Subject: [Mediawiki-api] [Mediawiki-api-announce] BREAKING CHANGE:
        Stricter validation of integer-type parameters
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="utf-8"

Various unusual values for integer-type parameters to the Action API will no longer be accepted. Acceptable values will consist of an optional sign (ASCII `+` or `-`) followed by 1 or more ASCII digits.

Values that were formerly allowed, and will now result in a "badinteger"
error, include:

   - Values with extraneous whitespace, such as " 1".
   - "1.9", formerly interpreted as "1".
   - "1e1", formerly interpreted as either "1" or "10" at various times.
   - "1foobar", formerly interpreted as "1"
   - "foobar", formerly interpreted as "0".

Most clients should already be using correct formats, unless they are taking direct user input without validation.

This change will most likely go out to Wikimedia wikis with 1.35.0-wmf.19.
See https://www.mediawiki.org/wiki/MediaWiki_1.35/Roadmap for a schedule.

--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20200204/3171202e/attachment-0001.html>
-------------- next part --------------
_______________________________________________
Mediawiki-api-announce mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce

------------------------------

Message: 3
Date: Tue, 4 Feb 2020 23:52:58 +0300
From: Furkan Gözükara <[hidden email]>
To: "MediaWiki API announcements & discussion"
        <[hidden email]>
Subject: Re: [Mediawiki-api] [Mediawiki-api-announce] BREAKING CHANGE:
        Parameter validation error codes
Message-ID:
        <[hidden email]>
Content-Type: text/plain; charset="utf-8"

How can i get file full path from file template?

For example * {{audio|en|en-us-dictionary.ogg|Audio (US, California)}}

On Tue, Feb 4, 2020 at 9:25 PM Brad Jorsch (Anomie) <[hidden email]>
wrote:

> The error codes that may be changing are some of those representing
> invalid values for API parameters. Notably, the following will change:
>
>    - "noX", indicating that a required parameter was not specified,
>    becomes "missingparam".
>    - "unknown_X", indicating that an unrecognized value was specified for
>    an enumerated-value parameter, becomes "badvalue".
>    - "too-many-X", indicating that too many values were supplied to a
>    multi-valued parameter, becomes "toomanyvalues".
>    - "baduser_X", "badtimestamp_X", and so on become "baduser",
>    "badtimestamp", and so on.
>
> Note this is not a comprehensive list, other codes may be changing as well.
>
> These changes make the error codes more predictable, at the expense of
> not indicating in the code which parameter specifically triggered the
> error. If you have a use case where knowing which parameter triggered
> the error is needed, please let us know (by replying to this message
> or by filing a request in Phabricator) and we'll add the necessary error metadata.
>
> The human-readable text is also changing for some of these errors
> (with or without error code changes), and for a few the error metadata
> may be changing (e.g. "botMax" changes to "highmax" for limit-type
> warnings in non-back-compat error formats).
>
> This change will most likely go out to Wikimedia wikis with 1.35.0-wmf.19.
> See https://www.mediawiki.org/wiki/MediaWiki_1.35/Roadmap for a schedule.
>
> --
> Brad Jorsch (Anomie)
> Senior Software Engineer
> Wikimedia Foundation
> _______________________________________________
> Mediawiki-api-announce mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce
> _______________________________________________
> Mediawiki-api mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.wikimedia.org/pipermail/mediawiki-api/attachments/20200204/2a5e7545/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api


------------------------------

End of Mediawiki-api Digest, Vol 150, Issue 4
*********************************************
_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: [Mediawiki-api-announce] BREAKING CHANGE: Parameter validation error codes

Bartosz Dziewoński
On 2020-02-22 10:59, Chen Xinyan wrote:
> Just out of curiosity, is there any recommended way to parse out "which" parameter goes wrong. For example, we have "unknown_action" before. Now it gets merged into "badvalue", and the response looks like this:
>
> ...
>
> Do I have to parse into .error.info content to know the parameter name?

You can use the 'errorformat=raw' parameter to get the internal data
used to construct the error message. It's mostly machine-readable, but I
don't think it comes with any documentation or compatibility guarantees,
the format could change at any time in new MW releases.

https://test2.wikipedia.org/w/api.php?action=test&errorformat=raw

For a long-term solution, I'd recommend filing a task to make the API
return this data in another way.


 > Would its content change (such as localized) under certain situation?

In the default format ('errorformat=bc') the error message is never
localized, but it can change in new MW releases without warning.

(If you wanted a localized message,
'errorformat=html'/'plaintext'/'wikitext' provides that, with the
language specified by 'errorlang'.)


--
Bartosz Dziewoński

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: [Mediawiki-api-announce] BREAKING CHANGE: Parameter validation error codes

Brad Jorsch (Anomie)
On Sat, Feb 22, 2020 at 4:34 PM Bartosz Dziewoński <[hidden email]> wrote:
On 2020-02-22 10:59, Chen Xinyan wrote:
> Just out of curiosity, is there any recommended way to parse out "which" parameter goes wrong. For example, we have "unknown_action" before. Now it gets merged into "badvalue", and the response looks like this:
>
> ...
>
> Do I have to parse into .error.info content to know the parameter name?

For a long-term solution, I'd recommend filing a task to make the API
return this data in another way.

As I said in the original announcement, "If you have a use case where knowing which parameter triggered the error is needed, please let us know (by replying to this message or by filing a request in Phabricator) and we'll add the necessary error metadata."

What's the use case, other than just curiosity?

--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api