mapbox / mapbox/mapbox-gl-js

Filter validation doesn't invalidate single boolean value

Open
#7,535 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

It looks like single boolean values are passing validation but results in invalid GL JSON. 🤔 It's not immediately clear why. [`getType` should be accounting for it](https://github.com/mapbox/mapbox-gl-js/blob/922d7b38c0466181fa6f0cebbec1e013ae59d475/src/style-spec/validate/validate_filter.js#L25-L27).

**mapbox-gl-style-spec version**: `13.2.1`

### Steps to Trigger Behavior

```js
import validateFilter from '@mapbox/mapbox-gl-style-spec/validate/validate_filter';
import styleSpec from '@mapbox/mapbox-gl-style-spec/reference/v8.json';

const errors = validateFilter({
key: '',
style: { glyphs: 'fake' },
styleSpec,
value: false
});

// []

```

### Expected Behavior

An entry in the error array indicating the boolean value provided is an invalid filter value.

### Actual Behavior

An empty error array returns resulting in no error found.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/style-spec/validate/validate_filter.js at the getType logic linked by the issue, then reproduce the supplied validateFilter call with value: false. Update validation so the call returns an error for the boolean value, and verify that the error array is no longer empty.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.