Page MenuHomePhabricator

Wikidata Query Service sometimes removes trailing slashes from Geonames URIs
Open, LowPublic


Ethan Gruber reported on Twitter that this query incorrectly returns a Geonames URI without a trailing slash:

  ?place a skos:Concept; 
  		   skos:prefLabel ?placeLabel;
           skos:exactMatch ?osgeo;
           skos:exactMatch ?tgn;
           skos:exactMatch ?geonames ;
           skos:exactMatch ?pleiades ;
           dct:coverage ?coord .
  ?place wdt:P1667 "7015539" .
  OPTIONAL {?place wdt:P3120 ?osgeoid .
  	BIND (uri(concat("", ?osgeoid)) as ?osgeo)
  OPTIONAL {?place wdt:P1667 ?tgnid .
  	BIND (uri(concat("", ?tgnid)) as ?tgn)}
  OPTIONAL {?place wdt:P1566 ?geonamesid .
  	BIND (uri(concat("", ?geonamesid, "/")) as ?geonames)}
  OPTIONAL {?place wdt:P1584 ?pleiadesid .
  	BIND (uri(concat("", ?pleiadesid)) as ?pleiades)}
  OPTIONAL {?place p:P625/ps:P625 ?coord}
  SERVICE wikibase:label {
	bd:serviceParam wikibase:language "en"

Note that he explicitly concatenates a "/" to it, yet it’s still not in the result:

wd:Q931172 42.418888888)

I managed to reduce it to this shorter query:

  BIND(<> AS ?g)
  OPTIONAL { BIND("" AS ?_) }

If the BIND is removed, or made non-optional, the bug doesn’t occur. It also doesn’t happen if you change anything in the domain part of the URI.

I assume this is related to the TrailingSlashRemovingInlineUriHandler that we register for Geonames URIs, though I’m not sure why it only seems to remove the slash in combination with an optional bind.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

VIAF IDs are also affected:

  BIND(<> AS ?g)
  OPTIONAL { BIND("" AS ?_) }

VIAF and Geonames seem to be the only cases where we use this TrailingSlashRemovingInlineUriHandler, though.

And note Ethan's assertion: The scheme for Geonames URIs requires a trailing forward slash.

Gehel triaged this task as Medium priority.Sep 15 2020, 7:47 AM
Gehel lowered the priority of this task from Medium to Low.Sep 2 2021, 1:37 PM