Page MenuHomePhabricator

Malformed response when no params provided
Closed, DeclinedPublic

Description

Author: M8R-udfkkf

Description:
When looking at

http://en.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop

It returns:

You are looking at the HTML representation of the XML format.
HTML is good for debugging, but probably is not suitable for your application.
See complete documentation, or API help for more information.

<?xml version="1.0"?>
<api />

This is not valid xml.

What it should return is: (as when you look at http://en.wikipedia.org/w/api.php?action=query&meta=siteinfo&sipro)

You are looking at the HTML representation of the XML format.
HTML is good for debugging, but probably is not suitable for your application.
See complete documentation, or API help for more information.

<?xml version="1.0"?>
<api>

<query>
  <general mainpage="Main Page" base="http://en.wikipedia.org/wiki/Main_Page" sitename="Wikipedia" generator="MediaWiki 1.16alpha-wmf" phpversion="5.2.4-2ubuntu5.7wm1" phpsapi="apache2handler" dbtype="mysql" dbversion="5.1.43-wm3193-log" rev="59858" case="first-letter" rights="Creative Commons Attribution-Share Alike 3.0 Unported" lang="en" fallback8bitEncoding="windows-1252" writeapi="" timezone="UTC" timeoffset="0" articlepath="/wiki/$1" scriptpath="/w" script="/w/index.php" variantarticlepath="" server="http://en.wikipedia.org" wikiid="enwiki" />
</query>

</api>

There is a related thread at WP:VPT (http://en.wikipedia.org/wiki/Wikipedia:Vpt#API_version)


Version: unspecified
Severity: minor
URL: http://en.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop

Details

Reference
bz22603

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 11:03 PM
bzimport set Reference to bz22603.

M8R-udfkkf wrote:

On second thought, it really should return an error message as http://en.wikipedia.org/w/api.php?action=query&meta=siteinfo&sifilteriw does

so it should return something like:

<?xml version="1.0"?>
<api>

<error code="siunknown_siprop" info="Unrecognized value for parameter &#040;siprop&#040;: " xml:space="preserve">

</api>

It should return some kind of error message, not a borked api message as it currently does.

M8R-udfkkf wrote:

http://en.wikipedia.org/w/api.php?action=query&metadvc also gives bad return...

Tmrw I'll open a small series of bugs after I check all the api modules.

Do you really mean version 1.3?

M8R-udfkkf wrote:

I thought I hit unspecified...oops.

M8R-udfkkf wrote:

I've looked at http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/api/ApiQuerySiteinfo.php and the problem is that it assumes there are parameters.

What it should say is something like this

public function execute() {
    $params = $this->extractRequestParams();
    if(empty($params))
        ApiBase :: dieDebug( __METHOD__, "No prop specified..." );
    else
    {
    $done = array();
    foreach ( $params['prop'] as $p )
    {
      ....

It could give better error handling, but it would suffice for now...

It's probably best to add something into extractRequestParams() to make it return an error code when no params are given, rather than go through and add if(empty($params)) to all of the api php scripts...

Bryan.TongMinh wrote:

If you don't specify something to return, it should not be unexpected that nothing it result.

The response is valid XML anyway: http://validator.w3.org/check?uri=http%3A%2F%2Fen.wikipedia.org%2Fw%2Fapi.php%3Faction%3Dquery%26meta%3Dsiteinfo%26siprop%26format%3Dxml&charset=%28detect+automatically%29&doctype=Inline&group=0

Recommending WONTFIX.

M8R-udfkkf wrote:

You are right, it is valid xml, just not well formed.

Looking at http://en.wikipedia.org/w/api.php?action=query&format=xml, it returns
<?xml version="1.0"?><api />

I'd like for it to return an error code as no parameter/prop specified.

I tend to agree with Bryan. You're requesting no information, I don't see why its wrong to return no information.

M8R-udfkkf wrote:

Well you are specifying which module.

If I do http://en.wikipedia.org/w/api.php?action=quey&format=xml
I do get an error response:
<api>
<error code="unknown_action" info="Unrecognized value for parameter 'action': quey"/>
</api>

But if I do http://en.wikipedia.org/w/api.php?action=query&format=xml
I get
<api/>

It should throw an error that no parameter was specified, not give no information.

Closing as WONTFIX per comment #7.