Page MenuHomePhabricator

Semantic Forms: Fix "Internal error in ApiFormatXml::recXmlPrint: (errors, ...) has integer keys without _element value."
Closed, ResolvedPublic

Description

Author: alj62888

Description:
Got this exception while using the api. Never saw it before and don't know what caused it. Does not happen with other same api calls with different values. I suspect it has something to do with the page title but not sure.

API call:

http://wiki-internal/wiki/api.php?action=sfautoedit&form=SusDataForm&target=SusData%3ADOESN%27T%20TRIGGER%20A%20FOURTH%20AMENDMENT%20REVIEW&query=SusData:CheckStatusTemplate[susCheckStatus]=PENDING%26SusData:CheckStatusTemplate[urlCheckStatus]=PENDING&format=xml

Result:

<?xml version="1.0"?><api><error code="internal_api_error_MWException" info="Exception Caught: Internal error in ApiFormatXml::recXmlPrint: (errors, ...) has integer keys without _element value. Use ApiResult::setIndexedTagName()." xml:space="preserve">

#0 /usr/local/errata/wiki/includes/api/ApiBase.php(1420): wfDebugDieBacktrace('Internal error ...')
#1 /usr/local/errata/wiki/includes/api/ApiFormatXml.php(179): ApiBase::dieDebug('ApiFormatXml::r...', '(errors, ...) h...')
#2 /usr/local/errata/wiki/includes/api/ApiFormatXml.php(194): ApiFormatXml::recXmlPrint('errors', Array, NULL)
#3 /usr/local/errata/wiki/includes/api/ApiFormatXml.php(80): ApiFormatXml::recXmlPrint('api', Array, NULL, false)
#4 /usr/local/errata/wiki/includes/api/ApiMain.php(847): ApiFormatXml-&gt;execute()
#5 /usr/local/errata/wiki/includes/api/ApiMain.php(823): ApiMain-&gt;printResult(false)
#6 /usr/local/errata/wiki/includes/api/ApiMain.php(369): ApiMain-&gt;executeAction()
#7 /usr/local/errata/wiki/includes/api/ApiMain.php(347): ApiMain-&gt;executeActionWithErrorHandling()
#8 /usr/local/errata/wiki/api.php(78): ApiMain-&gt;execute()
#9 {main}

</error></api>


Version: REL1_20-branch
Severity: minor
Platform: Other

Details

Reference
bz64777

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 3:09 AM
bzimport set Reference to bz64777.

action=sfautoedit is part of Semantic Forms -> moving

(In reply to Al Johnson from comment #0)

Got this exception while using the api. Never saw it before and don't know
what caused it. Does not happen with other same api calls with different
values. I suspect it has something to do with the page title but not sure.

Could you post a call that works?

alj62888 wrote:

The logs are gone, but I recall a previous permission error that was out of the ordinary. Testing this manually gives the same result when not logged-in. The pages namespace is restricted. I wouldn't have filed this bug if I had realized this... setting to minor.

Can be tested with the sfautoedit api examples.

alj62888 wrote:

Note: I didn't see the SemanticForms component in the dropdown on the commit page, so it changed to API again.

Please do not change it back to MediaWiki core's API component when the bug exists in an extension.

The error message you've reported indicates that the bug is in the SemanticForms extension, specifically in that it is failing to call ApiResult::setIndexedTagName on some numerically-indexed array it is giving to ApiResult as the value for an "errors" element somewhere. Checking https://wikitech.wikimedia.org/w/api.php?format=rawfm&action=sfautoedit&form=form-name&target=page-name&query=template-name[field-name-1]=field-value-1%26template-name[field-name-2]=field-value-2, I see that this is in fact the case.

Brad, could you elaborate on that? Following your link yields a perfectly correct error message for me ("<b>Form-name</b> is not a valid form.").

(In reply to s7eph4n from comment #6)

Brad, could you elaborate on that? Following your link yields a perfectly
correct error message for me ("<b>Form-name</b> is not a valid form.").

That's because I used &format=rawfm. This particular class of bugs only appears with &format=xml or &format=xmlfm.

But the output with &format=rawfm should be showing an additional subelement named "_element" on that errors element, as you can see for example on the pages element in https://wikitech.wikimedia.org/w/api.php?format=rawfm&action=query&titles=Foo.

Thanks for the hint, fixing this should be easy now.

alj62888 wrote:

(In reply to Brad Jorsch from comment #5)

Please do not change it back to MediaWiki core's API component when the bug
exists in an extension.

Brad, check the form as I indicated in my note. It required a value to submit.

(In reply to Al Johnson from comment #9)

(In reply to Brad Jorsch from comment #5)

Please do not change it back to MediaWiki core's API component when the bug
exists in an extension.

Brad, check the form as I indicated in my note. It required a value to
submit.

I don't know what form you're referring to, as both Umherirrender and I were able to assign it to SemanticForms without difficulty. And you were able to make comment 9 without being "forced" to change it.

(In reply to Al Johnson from comment #9)

Brad, check the form as I indicated in my note. It required a value to
submit.

Bugzilla only allows changing the product, a second page is displayed for updating the component. Components within products can be seen here: https://bugzilla.wikimedia.org/describecomponents.cgi
If there's any confusion, feel free to drop me a private email. :)

Yaron_Koren renamed this task from SemantixForms: Fix "Internal error in ApiFormatXml::recXmlPrint: (errors, ...) has integer keys without _element value." to Semantic Forms: Fix "Internal error in ApiFormatXml::recXmlPrint: (errors, ...) has integer keys without _element value.".Mar 4 2016, 5:52 PM
Yaron_Koren closed this task as Resolved.
Yaron_Koren subscribed.

I'm missing that this has been fixed, since I haven't heard of this error outside of this one bug report... feel free to re-open if not.

If nothing else it was likely fixed by rMW1c57794e371d: API: Overhaul ApiResult, make format=xml not throw, and add json formatversion which removed that exception. There's still potentially metadata you could add to make the XML output more user-friendly, but it should be usable as-is.

Ah! That seems like it would explain it.

(And I wrote "missing" instead of "guessing" before, but you probably figured that out.)