Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression migrator generates invalid style if icon-image value is a categorical function #10056

Closed
samanpwbb opened this issue Oct 28, 2020 · 0 comments · Fixed by #10060
Closed
Assignees
Labels

Comments

@samanpwbb
Copy link
Contributor

samanpwbb commented Oct 28, 2020

mapbox-gl-js version: latest 1.x.x

browser: N/A

Steps to Trigger Behavior

  1. Attempt to migrate a style that uses a categorical function on the text-image field.
  2. See validation error.

Link to Demonstration

#10055

Expected Behavior

Migrated style is valid. I see two ways to fix this problem:

  1. Make migrator insert an empty string as fallback value for icon-image when migrating categorical expression.
  2. Make GL JS support undefined values for icon-image.

I can take care of fixing this if someone on GL JS has a preferred approach between those two. I'm thinking using an empty string as fallback is the best option. This can be fixed by adjusting the logic around categorical conversion for image type values:

expression.push(convertLiteral(coalesce(parameters.default, propertySpec.default)));
– this line can resolve to undefined, leading to an invalid style.

Actual Behavior

Migrated style is not valid.

// Input
{
  base: 1,
  type: 'categorical',
  property: 'type',
  stops: [['park', 'some-icon']]
}
// Output
[ 'match', [ 'get', 'type' ], 'park', 'some-icon', undefined ]

Error: "layers[0].layout.icon-image[4]: 'undefined' value invalid. Use null instead."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant