-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Literal expression validation does not match documentation #9308
Comments
@dereklieu Here's a comment from the parsing code: mapbox-gl-js/src/style-spec/expression/parsing_context.js Lines 122 to 125 in d5bce5a
Internally, some expressions may be computable at compile time and folded into constants, and continue to be represented by I think the documentation is correct to recommend using cc @ryanhamley |
Sounds good - this seems like a docs issue then. We will loosen the validation causing this error in Studio. |
I'm confused by the Studio validation on this. This is much stricter than how the The expression will accept any mapbox-gl-js/src/style-spec/expression/definitions/literal.js Lines 21 to 44 in 517b39f
This function shows what is considered a valid mapbox-gl-js/src/style-spec/expression/values.js Lines 34 to 68 in 517b39f
We might want to adjust the documentation to make it clearer that the Edit: I hadn't seen @dereklieu 's comment about loosening the validation before posting this but it seems like we're on the same page then |
Yeah @ryanhamley my guess based on the code is that we followed the docs which gives the strong impression that you're only supposed to use arrays and objects. Studio doesn't support object types yet, hence the validation. |
The style spec documentation for literal expressions says it requires an array or object in the second argument. However, in Studio, an expression like the one below passes validation.
[ "literal", "#333333" ]
mapbox-gl-js version:
@mapbox/mapbox-gl-style-spec@13.11.0
browser: N/A
Steps to Trigger Behavior
Save this style, upload to Studio, and try clicking on the single layer.
I'm sorry I don't have a better way to illustrate this, but Studio uses validator functions when you try uploading any style.
This causes issues in our json editor, which enforces Studio limitations around object literals and only allows arrays in
literal
expressions.I'm not sure how long this behavior has been around, but it's likely that stricting up this validation could break production styles. It would be worth seeing how many styles this would affect, cc @samanpwbb.
The text was updated successfully, but these errors were encountered: