Last modified: 2014-06-30 13:29:18 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T47277, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 45277 - Improve localizable error messages for API calls
Improve localizable error messages for API calls
Status: VERIFIED FIXED
Product: MediaWiki extensions
Classification: Unclassified
WikidataRepo (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Wikidata bugs
:
Depends on:
Blocks: repoapi 52843 62824
  Show dependency treegraph
 
Reported: 2013-02-22 13:35 UTC by Daniel Kinzler
Modified: 2014-06-30 13:29 UTC (History)
7 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Daniel Kinzler 2013-02-22 13:35:25 UTC
Wikibase API modules currently often provide a localized error info when calling ApiBase::dieUsage. This is inconsistent with current practice in core, and insufficient for providing localized errors in the UI.

Instead, we should use a new call like dieUsageWithMessage, providing an error code an a Message objects (or message key and parameters). An unlocalized error info may be added, but seems redundant. 

This should work similarly to the error reports generated from Status objects, as introduced by I4094feee as a solution to bug 45099. 

Note that ApiBase::dieUsageMsg() is similar, but insufficient (as it doesn't provide message keys and parameters to the caller). Also, it requires us to define a mapping between error codes and messages, which is painful to maintain, and non-obvious to use.
Comment 1 Daniel Kinzler 2013-07-09 13:20:48 UTC
After several discussions with Wikibase and MediaWiki core developers, it seems that for the use case of bots, unlocalized, hard coded error messages are preferred. However, when showing an error in the UI, we want a localized message. 

Suggestion:

* For all errors arising from the client not conforming to the requirements of the API module (missing or malformed parameters, etc), use hard coded english messages.

* For errors resulting from user input or system state (edit conflict, db is read only, etc), use a localized message. These will usually come from a Status object. ApiWikibase::handleStatus() implements this logic.
Comment 2 Brad Jorsch 2013-07-10 14:58:07 UTC
(In reply to comment #1)
> * For errors resulting from user input or system state (edit conflict, db is
> read only, etc), use a localized message. These will usually come from a
> Status
> object. ApiWikibase::handleStatus() implements this logic.

So if a bot runs into an edit conflict it gets a message in some unexpected language, possibly full of HTML and local-wiki customizations?
Comment 3 Daniel Kinzler 2014-04-07 11:12:15 UTC
Picking this up again after some time: Error reporting in Wikibase API modules needs to be rewritten. Here are some key points (not a full spec):

* We need a helper class that for handling errors.
* We want to be able to report errors by code, based on an Exception, and based on a Result object.
* We want to stay compatible with the core APIs way of reporting errors (plain english message plus an error code).
* In addition, we want to provide localized, HTML formatted messages where possible.
* Error localization should be factored into appropriate components, for mapping codes resp. Exceptions to Message objects.
* We want a way to provide "codes" for warnings too, e.g. for indicating a null-edit or a auto-resolved edit conflict or self-conflict.
Comment 4 Gerrit Notification Bot 2014-04-15 15:38:52 UTC
Change 124323 merged by jenkins-bot:
(bug 45277) Introducing ApiErrorReporter

https://gerrit.wikimedia.org/r/124323

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links