Error loading style from URL: string expected, array found
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: 3.9.2
**browser**: Electron (Chromium)
### Steps to Trigger Behavior
1. Fetch style from url: https://api.mapbox.com/styles/v1/mapbox/standard?access_token=pk.XXX
2. Create new mapbox with retrieved style object
```
fetch(`https://api.mapbox.com/styles/v1/mapbox/standard?access_token=${accessToken}`)
.then(r => r.json())
.then(style => {
const mapBox = new mapboxgl.Map({
accessToken,
container: 'mapbox-container',
style,
center: [0, 0],
interactive: false,
trackResize: false,
preserveDrawingBuffer: true,
performanceMetricsCollection: false
});
});
```
### Expected Behavior
The map should load correctly. This used to work correctly until recently, and is actually working well if I update mapbox-gl-js to the latest version, but for users that are stuck with an old version this has stopped working.
### Actual Behavior
The map fails to load. Something seems to have changed on the server side that breaks previously working versions.
```
Error: imports[0].data.sources.composite.promoteId.building: string expected, array found
at _emitValidationErrors (./node_modules/mapbox-gl/src/style/validate_style.ts:18:45)
at emitValidationErrors (./node_modules/mapbox-gl/src/style/style.ts:140:5)
at xo._load (./node_modules/mapbox-gl/src/style/style.ts:747:25)
at xo._load (./node_modules/mapbox-gl/src/style/style.ts:741:18)
at ./node_modules/mapbox-gl/src/style/style.ts:589:18
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with mapbox-gl-js 3.9.2 and the fetched Standard style, then inspect the validation path in src/style/validate_style.ts and src/style/style.ts. Compare the promoteId.building value and validation behavior with a current version. Done means the reported style loads successfully for the affected older client, with coverage for the regression if the repository provides a suitable style-loading test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100