mapbox / mapbox/mapbox-gl-js

validate property names in getPaintProperty

Open
#6,033 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

api :memo: good first issue
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

`map.setPaintProperty(layer, key value)` validates arguments but `map.getPaintProperty` does not. Providing a bad property key will trigger an internal error. It should trigger an error with a helpful errror message. Seen here: https://github.com/mapbox/mapbox-gl-js/issues/6030

**mapbox-gl-js version**: v0.43.0 and master

### Steps to Trigger Behavior

1. `map.getPaintProperty("background", "fill-radius");`

### Expected Behavior

something like:
`"fill-radius" is not a paint property background layers"`

### Actual Behavior

`Uncaught TypeError: Cannot read property 'value' of undefined`

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 at the map.getPaintProperty entry point and compare its argument handling with map.setPaintProperty, using the reported background and fill-radius call as the reproduction. Verify that an invalid property produces a helpful validation error rather than the internal TypeError; the issue is done when this behavior is covered and working.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.