Skip to content

(filter) expected one of [==, !=, >, >=, <, <=, in, !in, all, any, none, has, !has, within], "match" found" #555

Description

@tordans

Describe the bug

I am getting console error messages about filters which do work but still produce an error. I don't understand why they would be wrong or how to change them to prevent the error. I am merging filters in React (using react-map-gl) and only really have control over some of the filters but the external filters.

I can reproduce the error when adding a filter to the integration tests.

To Reproduce online

Steps to reproduce the behavior:

  1. Go to https://www.osm-verkehrswende.org/cqi/map/?map=12%2F13.39%2F52.518&anzeige=incompleteness
  2. Select any of the legend items to filter, eg. "Sehr unvollständig"
  3. See console: Error: layers.lane markings dashed.filter[2][0]: expected one of [==, !=, >, >=, <, <=, in, !in, all, any, none, has, !has, within], "match" found

To Reproduce in tests

  1. Open test/integration/style-spec/tests/filters.input.json
  2. Append
        {
          "id": "mixing `match` with `==`",
          "type": "line",
          "source": "source",
          "source-layer": "source-layer",
          "filter": ["all", ["==", "Constructi", 1930], ["match", ["get", "Constructi"], [1930], true, false]]
        }
  3. Run npm run test-integration
    +   },
    +   ValidationError {
    +     "line": 166,
    +     "message": "layers[16].filter[2][0]: expected one of [==, !=, >, >=, <, <=, in, !in, all, any, none, has, !has, within], \"match\" found",
        },

Expected behavior
I expect match filters to be valid filters the same as ==

Additional context

I was wondering it the issue is, that match has a return type of OutputType according to https://maplibre.org/maplibre-style-spec/expressions/#match whereas other listed "allowed" filter return boolean (eg in https://maplibre.org/maplibre-style-spec/expressions/#in) and all expect boolean https://maplibre.org/maplibre-style-spec/expressions/#all

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions