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(a)lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-tech