Page MenuHomePhabricator

Error with curly braces in selector (eg when using subquery or UNION)
Closed, ResolvedPublic

Description

I'm not really sure if this should be able to be supported, but the error messages says to report it so I am. :-)

The error is: <class 'IndexError'> list index out of range with the following input:

{{Property dashboard
|selector_sparql=wdt:P17 wd:Q408; wdt:P31 ?type . { SELECT * WHERE { ?type wdt:P279 wd:Q7075 } }
|grouping_property=P131
|higher_grouping=wdt:P131
|properties=P625,P18,P6375
|stats_for_no_group=1
|grouping_threshold=0
|property_threshold=0
}}

The idea is to select all entities of a type or any subtype (in this case, libraries and things like public libraries, academic libraries, etc.).

Another example that fails:

{{Property dashboard
|selector_sparql= p:P31 []. {?entity wdt:P69 wd:Q309350.} UNION {?entity wdt:P69 wd:Q6806876. }
|grouping_property=P21
|grouping_threshold=1
|stats_for_no_group=False
|properties=P18,Len,P244,P214,P496,P2381
}}

Event Timeline

Thanks for reporting this :)

I reproduced it with your inputs at https://www.wikidata.org/wiki/User:Jean-Fr%C3%A9d%C3%A9ric/T240312

Unfortunately, this is very mysterious, and can only come from an upstream pywikibot issue. I pushed 257618f188b that the failure is a bit more graceful at least.

Will also try again after upgrading pywikibot to the latest version.

Mentioned in SAL (#wikimedia-cloud) [2019-12-11T15:15:42Z] <wm-bot> <jeanfred> Deploy latest from Git master: 257618f1 (T240312)

Pywikibot upgrade to latest version did not help :-( . I’ll dig deeper and file an issue upstream.

JeanFred renamed this task from Error with subquery in selector to Error with curly braces in selector (eg when using subquery or UNION).Mar 24 2021, 8:50 PM

I tried again upgrading pywikibot to latest version 6.0.1, no changes. Filed T278454: templatesWithParams misses template where a parameter value has a curly brace for this.

Mentioned in SAL (#wikimedia-cloud) [2021-03-26T20:55:25Z] <wm-bot> <jeanfred> Deploy latest from Git master: bcc4fe41 (T240312)

Mentioned in SAL (#wikimedia-cloud) [2021-03-26T20:57:53Z] <wm-bot> <jeanfred> Reinstalled requirements in both virtual environments for T240312

Thanks to Xqt guidance over at T278454, I added mwparserfromhell as a dependency. The minimal reproduction example is now working \o/ − see https://www.wikidata.org/wiki/User:Jean-Fr%C3%A9d%C3%A9ric/T240312

JeanFred claimed this task.