Page MenuHomePhabricator

Map is broken after adding a line manually in VE
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Create a geoline manually in the VE interface.
  • Save the page.

What happens?:
The map is empty in static mode. Dynamic mode is still showing the map with the line.

Screenshot from 2022-05-17 16-01-57.png (408×387 px, 5 KB)

Error message: Failed to parse color: \"#function fill() { [native code] }\

See also https://wiki.alquds.edu/?query=Wikipedia:Village_pump_(technical)/Archive_189#Mapframe_showing_ocean_in_saved_page

What should have happened instead?:
The map should be displayed correctly with markers and the line.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:
Looks like the automatically created empty property field is creating an issue. Because removing that solved the issue.

Event Timeline

Sounds like we might want to fix whatever parsing is happening inside the code running on maps.wikimedia.org -- it should probably treat an empty properties object the same as an entirely absent one.

Failing that, the extension generating the mapframe tag could be updated to not output this.

There are an awful lot of "Failed to parse color" errors, roughly 40,000 per day. As part of investigating this task, we should make sure that the error is handled gracefully, e.g. a default color is used.

I tried to dig a bit into the code:

My current guess is that we updated something to a more recent version, but forgot to update a dependency. It appears like some code intentionally feeds functions to a library for some kind of indirection. The library is supposed to resolve the function by calling it, but instead fails with the error message we see.

I imagine that VE controls the wiring between its input field and the lower-level libraries, so perhaps we just strip the empty properties out at the step of sending this text to the library?

That one is a test file so not relevant.

I'm afraid this might be coming from the native dependency. I can't find the string anywhere else in kartotherian or its node_modules.

root@99ff4d40246e:/usr/lib# strings libmapnik.so.3.0.22  | grep 'Failed to parse color'
Failed to parse color: "

We discovered that the error starts with bad output from the mapdata API. An empty properties object "properties": {} in GeoJSON gets reserialized by Kartographer as an array, and is sent back to geoshapes as an array, properties: []. We need to fix the output from the mapdata API.

Change 802785 had a related patch set uploaded (by Awight; author: Awight):

[mediawiki/extensions/Kartographer@master] Set empty properties to null

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

Change 802891 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Kartographer@master] Force empty properties to be JSON serialized as an object

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

An empty properties object […] gets reserialized by Kartographer as an array

Uh, nice find! The JSON serializer responsible for this is FormatJson from core. There is even a comment that explains "Empty arrays are encoded as numeric arrays, not as objects, so cast any associative array that might be empty to an object before encoding it." I gave it a try: https://gerrit.wikimedia.org/r/802891

Change 802785 abandoned by Awight:

[mediawiki/extensions/Kartographer@master] Set empty properties to null

Reason:

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

Change 802891 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Force empty properties to be JSON serialized as an object

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

I found this morning in logstash an undefined offset in Kartographer which I have filed as T311037 , it might be related to a recent fix made for this task?

awight claimed this task.
awight moved this task from In sprint to Ready for pickup on the WMDE-GeoInfo-FocusArea board.
awight moved this task from Ready for pickup to In sprint on the WMDE-GeoInfo-FocusArea board.