osm-fr / osmose-frontend

Part of osmose that shows results on the website http://osmose.openstreetmap.fr
GNU General Public License v3.0
41 stars 38 forks source link

Internal server errors for benches with direction #401

Closed Nadyita closed 1 year ago

Nadyita commented 1 year ago

I'm getting an internal server error every time I'm trying to open the details for 3 issues (like this one)

All 3 issues seem to be related to benches with the following attributes:

amenity=bench
backrest=yes
direction=125
material=wood
seats=4

I don't see any issues with these attributes, but something is definitely causing the API to return a 500, and you might want to investigate what. These are the only benches with a direction-attribute in the area, so I'm positively sure it's related to this.

frodrigo commented 1 year ago

This issue is related to the new version of analyser result upload API, currently under beta test.

In fact it corrupts a database jsonb field by double encoding it.

frodrigo commented 1 year ago

Fixing the corrupted data and the code.

UPDATE
    markers
SET
    elems = (SELECT array_agg((elem #>> '{}')::jsonb) FROM unnest(elems) AS elem)
WHERE
    elems IS NOT NULL AND
    jsonb_typeof(elems[1]) = 'string'
;
UPDATE
    markers
SET
    fixes = (SELECT array_agg((elem #>> '{}')::jsonb) FROM unnest(fixes) AS elem)
WHERE
    fixes IS NOT NULL AND
    jsonb_typeof(fixes[1]) = 'string'
;