'Coalesce' fails to find fallback image with 'fill-pattern' and 'line-pattern'
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**: v2.5.0
**browser**: Chrome & Firefox
### Steps to Trigger Behavior
Create a [fallback image expression](https://docs.mapbox.com/mapbox-gl-js/example/fallback-image/) for a line or polygon. Example:
```js
'fill-pattern': [
"coalesce",
["image", ["get", "icon"]],
["image", "rocket-15"],
]
```
I think that this will occur with any expression that meets the following:
- for `fill-pattern` or `line-pattern`
- with `coalesce`
- and with at least one `image` wrapping a `get`
### [Link to Demonstration](https://codepen.io/snailbones/pen/OJjLYVK?editors=1011)
### Expected Behavior
The area with an invalid image name should display as the fallback rocket icon.

### Actual Behavior
The area with an invalid image name doesn't render. The console displays:
> "Image 'missing-icon' could not be loaded. Please make sure you have added the image with map.addImage() or a 'sprite' property in your style. You can provide missing images by listening for the 'styleimagemissing' map event."

Oddly, changing the second `image` expression to a string leads to ALL polygons displaying the fallback image:
```js
'fill-pattern': [
"coalesce",
["image", ["get", "icon"]],
"rocket-15"
]
```

When a `get` statement is included, ALL 'image' expressions inside of the `coalesce` seem to evaluate to false.
@arindam1993 thoughts on why this might be happening?
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
Start by reproducing the issue in the linked CodePen using the reported fill-pattern and line-pattern coalesce expressions. Trace how image expressions containing get are evaluated, and consider the issue complete when an invalid image name displays the rocket fallback without preventing valid pattern rendering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100