Hi,
I am wondering how errors and warnings are reported through the API, and which errors and warnings are possible. There is some documentation on Wikidata errors [1], but I could not find documentation on how the warning messages are communicated in JSON. I have seen structures like this:
{ "warnings" : {"wbeditentity": {"messages": [{"name":"wikibase-self-conflict-patched", "parameters":[], "html": { "*":"Your edit was patched into the latest version, overriding some of your own intermediate changes."} }] } } }
I don't know how to provoke more warnings, or multiple warnings in one request, so I found it hard to guess how this pattern generalises. Some questions:
* What is the purpose of the map with the "*" key? Which other keys but "*" could this map have? * The key "wbeditentity" points to a list. Is this supposed to encode multiple warnings of this type? * I guess the "name" is a message name, and "parameters" are message "arguments" (as they are called in action="query") for the message? * Is this the JSON pattern used in all warnings or can there also be other responses from wbeditentity? * Is this the JSON pattern used for warnings in all Wikibase actions or can there also be other responses from other actions? * Is there a list of relevant warning codes anywhere? * Is there a list of relevant error codes anywhere? The docs in [1] point to paraminfo (e.g., http://www.wikidata.org/w/api.php?action=paraminfo&modules=wbeditentity) but there are no errors mentioned there.
Thanks,
Markus
<Push>
A partial answer would also be helpful (maybe some of my questions are more tricky than others).
Thanks,
Markus
On 28.08.2015 10:41, Markus Krötzsch wrote:
Hi,
I am wondering how errors and warnings are reported through the API, and which errors and warnings are possible. There is some documentation on Wikidata errors [1], but I could not find documentation on how the warning messages are communicated in JSON. I have seen structures like this:
{ "warnings" : {"wbeditentity": {"messages": [{"name":"wikibase-self-conflict-patched", "parameters":[], "html": { "*":"Your edit was patched into the latest version, overriding some of your own intermediate changes."} }] } } }
I don't know how to provoke more warnings, or multiple warnings in one request, so I found it hard to guess how this pattern generalises. Some questions:
- What is the purpose of the map with the "*" key? Which other keys but
"*" could this map have?
- The key "wbeditentity" points to a list. Is this supposed to encode
multiple warnings of this type?
- I guess the "name" is a message name, and "parameters" are message
"arguments" (as they are called in action="query") for the message?
- Is this the JSON pattern used in all warnings or can there also be
other responses from wbeditentity?
- Is this the JSON pattern used for warnings in all Wikibase actions or
can there also be other responses from other actions?
- Is there a list of relevant warning codes anywhere?
- Is there a list of relevant error codes anywhere? The docs in [1]
point to paraminfo (e.g., http://www.wikidata.org/w/api.php?action=paraminfo&modules=wbeditentity) but there are no errors mentioned there.
Thanks,
Markus
[1] https://www.mediawiki.org/wiki/Wikibase/API#Errors
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
I now identified another format for API warnings. For example, I got the following from action "watch":
"warnings": { "watch": { "*": "The title parameter has been deprecated." } }
For comparison, here is again what I got from wbeditentity:
"warnings" : {"wbeditentity": {"messages": [{"name":"wikibase-self-conflict-patched", "parameters":[], "html": { "*":"Your edit was patched into the latest version, overriding some of your own intermediate changes."} }] } }
For action "paraminfo", I managed to trigger multiple warnings. Guess how three warnings are reported there!
"warnings": { "paraminfo": { "*": "The mainmodule parameter has been deprecated.\nThe pagesetmodule parameter has been deprecated.\nThe module "main" does not have a submodule "foo"" } }
I will now implement these two forms. The "html":{"*":"..."} form seems a bit risky to implement (will it always be "html"? will it always be "*"?), but I could not get any other warning in such a form, so this is the one I will support.
I wasted some time with trying to trace this in the PHP code, but did not get to the point where the "messages" or even "html" key is inserted. I got as far as ApiResult.php, where messages end up being added in addValue(). It seems that this is the same for all modules, more or less. I lost the trace after this. I have no idea what happens with the thus "added" messages or how they might surface again elsewhere in this code. There are various JsonFormatter classes but they are very general and do not mention "messages". Neither do the actual ApiMessage objects.
Markus
On 30.08.2015 14:22, Markus Krötzsch wrote:
<Push>
A partial answer would also be helpful (maybe some of my questions are more tricky than others).
Thanks,
Markus
On 28.08.2015 10:41, Markus Krötzsch wrote:
Hi,
I am wondering how errors and warnings are reported through the API, and which errors and warnings are possible. There is some documentation on Wikidata errors [1], but I could not find documentation on how the warning messages are communicated in JSON. I have seen structures like this:
{ "warnings" : {"wbeditentity": {"messages": [{"name":"wikibase-self-conflict-patched", "parameters":[], "html": { "*":"Your edit was patched into the latest version, overriding some of your own intermediate changes."} }] } } }
I don't know how to provoke more warnings, or multiple warnings in one request, so I found it hard to guess how this pattern generalises. Some questions:
- What is the purpose of the map with the "*" key? Which other keys but
"*" could this map have?
- The key "wbeditentity" points to a list. Is this supposed to encode
multiple warnings of this type?
- I guess the "name" is a message name, and "parameters" are message
"arguments" (as they are called in action="query") for the message?
- Is this the JSON pattern used in all warnings or can there also be
other responses from wbeditentity?
- Is this the JSON pattern used for warnings in all Wikibase actions or
can there also be other responses from other actions?
- Is there a list of relevant warning codes anywhere?
- Is there a list of relevant error codes anywhere? The docs in [1]
point to paraminfo (e.g., http://www.wikidata.org/w/api.php?action=paraminfo&modules=wbeditentity) but there are no errors mentioned there.
Thanks,
Markus
[1] https://www.mediawiki.org/wiki/Wikibase/API#Errors
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
On Tue, Sep 1, 2015 at 7:45 AM, Markus Krötzsch < markus@semantic-mediawiki.org> wrote:
I now identified another format for API warnings.
Obviously such variability in error reporting is going to cause consumers of the API aggravation. Perhaps a single, consistent reporting style could be developed.
Tom
Hi,
I now identified another format for API warnings [...] from action "watch"
I'm not absolutely sure, but I think this is not really an other format. The "warnings" field contains a list of modules. For each module you can either have a list of "messages", or a plain string. In the later case the string is stored with the "*" key you see in both examples.
The relevant code that creates these "warnings" structures for Wikibase can be found in the ApiErrorReporter class.
The { "name": ..., "parameters": ..., "html": { "*": ... } } thing you see is a rendering of a Message object. The "html" key can be seen in \ApiErrorFormatter::addWarningOrError, the "*" is a result from the Message class.
Hope that helps.
Best Thiemo
On 01.09.2015 16:57, Thiemo Mättig wrote:
Hi,
I now identified another format for API warnings [...] from action
"watch"
I'm not absolutely sure, but I think this is not really an other format. The "warnings" field contains a list of modules. For each module you can either have a list of "messages", or a plain string. In the later case the string is stored with the "*" key you see in both examples.
The relevant code that creates these "warnings" structures for Wikibase can be found in the ApiErrorReporter class.
The { "name": ..., "parameters": ..., "html": { "*": ... } } thing you see is a rendering of a Message object. The "html" key can be seen in \ApiErrorFormatter::addWarningOrError, the "*" is a result from the Message class.
Hope that helps.
Yes, this is very helpful. Thanks. I had looked at this PHP code, but I could not see these things there (strings like "*" are not very distinctive, so I was not sure which "*" I am looking at ;-).
Markus
Hi Markus,
for reference, our error message parsing happens in WikibaseJavaScriptApi: https://git.wikimedia.org/blob/mediawiki%2Fextensions%2FWikibaseJavaScriptAp... This is only used for parsing errors returned by Wikibase API modules, though.
On Tue, Sep 1, 2015 at 5:17 PM, Markus Krötzsch markus@semantic-mediawiki.org wrote:
On 01.09.2015 16:57, Thiemo Mättig wrote:
Hi,
I now identified another format for API warnings [...] from action
"watch"
I'm not absolutely sure, but I think this is not really an other format. The "warnings" field contains a list of modules. For each module you can either have a list of "messages", or a plain string. In the later case the string is stored with the "*" key you see in both examples.
The relevant code that creates these "warnings" structures for Wikibase can be found in the ApiErrorReporter class.
The { "name": ..., "parameters": ..., "html": { "*": ... } } thing you see is a rendering of a Message object. The "html" key can be seen in \ApiErrorFormatter::addWarningOrError, the "*" is a result from the Message class.
Hope that helps.
Yes, this is very helpful. Thanks. I had looked at this PHP code, but I could not see these things there (strings like "*" are not very distinctive, so I was not sure which "*" I am looking at ;-).
Markus
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
wikidata-tech@lists.wikimedia.org