mapcentia / geocloud2

The GC2 framework helps you build a spatial data infrastructure quickly and easily. Powered using open source components for a scalable solution focused on freedom rather than fees.
https://www.osgeo.org/projects/gc2-vidi/
GNU Affero General Public License v3.0
148 stars 67 forks source link

Error on empty sort_id #142

Open giovanniborella opened 5 months ago

giovanniborella commented 5 months ago

Failures observed:

Each of the services til return an error like:

{"success":false,"message":"Unsupported operand types: int - string","code":500}

The cause of this is an empty value in the fieldconf of a featuretype. if the value of "sort_id" is "" (empty string) PHP will fail.

I've used this to find the relevant information in settings.geometry_columns_join:

SELECT 
    _key_,
    key AS json_key, 
    value->>'sort_id' AS sort_id 
FROM settings.geometry_columns_view, jsonb_each(fieldconf::jsonb)
    WHERE value->>'sort_id' IS NULL OR value->>'sort_id' = ''

if your table is very old, fieldconf might not be valid json and the statement will throw errors.

i suggest a check for null/empty values and default to 0 when getting the information.