Skip to content

[ogcapi-features] routing error if identifier contains '/' #7422

Open

Description

@pvgenuchten

In case the value of an identifier property of a feature includes a '/', the routing fails
Url-encoding the value doesn't seem to improve the case (Apache decodes the URL before launching CGI, unless apache is configured to keep slashes; AllowEncodedSlashes NoDecode)
Same probably applies to special characters such as "?/&"

https://kenya.lsc-hubs.org/ows/vector/ogcapi/collections/Potato_suitability/items/KE104/2-149 vs
https://kenya.lsc-hubs.org/ows/vector/ogcapi/collections/Potato_suitability/items/KE104%2F2-149

{"code":"NotFound","description":"Invalid API path."}

Activity

  1. jratike80 commented on Feb 3, 2026

    @jratike80

    As far as I know, "/" in url is a path separator and cannot appear in the "filename" part. As url-encoded "%2F" it could work in theory, but as you noticed, servers may not agree.
    The OGC API Features working group has discussed about the topic in opengeospatial/ogcapi-features#156. I think that the consensus was that special characters are allowed as percent encoded, but not recommended.

  2. geographika commented on Feb 3, 2026

    @geographika
    Member

    @jratike80 - I presume this means MapServer should do the encoding/decoding, rather than have Ids in a dataset with encoded values?

  3. jratike80 commented on Feb 3, 2026

    @jratike80

    I don't know how it could ever work really. Consider the default JSON output
    https://kenya.lsc-hubs.org/ows/vector/ogcapi/collections/Potato_suitability/items?f=json&limit=1&offset=0

    The featureId in the response comes from the source data, I guess "id": "KE104/2-149". User or client should know to convert it into ...items/KE104%2F-149. But if Apache and others by default decodes the values then nothing helps.

    @pvgenuchten , does KE104/2-149 work with pygeoapi or geoserver? If the issue is critical for you, please create a ticket at https://github.com/opengeospatial/ogcapi-features/issues/ and ask the standardization folks how the support for slashes in featureId should be implemented. For collectionIds it feels easier to implement because the links https://kenya.lsc-hubs.org/ows/vector/ogcapi/collections?f=json could be made to show the correct percent encoding.

    I believe I would take a safe way, edit the data and create new URL-friendly featureids that would work with any OGCFeat server without tricks. Another option would be to query the id field with query or with cql2 but I must admit that I have never used MapServer OGC API Features myself. Is it so that we do not support any kind of queries/filters?

  4. pvgenuchten commented on Feb 3, 2026

    @pvgenuchten
    Author

    Thanx for your thoughts, I agree it’s not optimal from general web perspective
    Pygeoapi (and underlying flask) has support for parameters of type path (with slashes) https://testdriven.io/tips/24431240-a8bf-437d-82ba-72507d4fb5a0/

    But fully understand if we neglect the case, maybe add a note in docs

  5. pvgenuchten commented on Feb 3, 2026

    @pvgenuchten
    Author

    I presume this means MapServer should do the encoding/decoding, rather than have Ids in a dataset with encoded values?

    Actually in my case Apache decodes before passing to cgi, let me give a try to the AllowEncodedSlashes directive in https.conf
    Setting this parameter seems quite common when hosting rest api’s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions