mapbox / mapbox/mapbox-gl-js

String tokens used outside stop functions aren't migrated to expressions

Open
#10,930 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**mapbox-gl-js version**: Latest

**browser**: Chrome

### Steps to Trigger Behavior

1. Create a new style in Studio
2. Replace the text-field of the `poi-label` layer (or any other Streets layer) with a string token `{name}` used in your style.json
2. Upload the style to Studio
3. Open the style and see the `{name}` string token persisting as the text-field for the `poi-labels` layer

[Copiable link](https://api.mapbox.com/styles/v1/kelsey-taylor/cks9eqaai013m17t2x8smuil3.html?fresh=true&title=copy&access_token=pk.eyJ1Ijoia2Vsc2V5LXRheWxvciIsImEiOiJjazJ3ZWl2a2YwZHU2M21xbDJnYXA2Z29tIn0.pnZVgZveufjFh20yW0ZI7g) to style

### Expected Behavior

`{name}` should be converted into `["to-string", ["get", "name"]]` via the expression migrator

### Actual Behavior

per @samanpwbb, string tokens are only migrated if they're not on the root of the style: https://github.com/mapbox/mapbox-gl-js/blob/dc8a6308ce3f072b6d87ff556721d1401b8a1f5b/src/style-spec/function/convert.js#L246-L269 https://github.com/mapbox/mapbox-gl-js/blob/dc8a6308ce3f072b6d87ff556721d1401b8a1f5b/src/style-spec/function/convert.js#L24-L26

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/function/convert.js at the referenced lines and trace why string tokens on the style root bypass migration. Add coverage for a root-level {name} token and verify that it becomes ["to-string", ["get", "name"]] through the expression migrator.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.