Fix promoteId crash on features with null properties - #194
Merged
Conversation
promoteId read geojson.properties[options.promoteId] without a null guard, so a feature with properties: null (valid GeoJSON per RFC 7946) threw a TypeError and crashed the whole geojsonvt() call. The other id paths (generateId, none) already tolerate null properties. Guard the access so a null-properties feature resolves to no id, as it does for a missing property key.
mourner
approved these changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
promoteIdthrows and crashes the wholegeojsonvt(...)call when a feature hasproperties: null, which is valid GeoJSON (RFC 7946 section 3.2 allows a nullpropertiesmember).A single such feature anywhere in the input produces no tiles. The other id paths already tolerate null properties:
generateId: trueworks, and no id option works, so this is an inconsistency in thepromoteIdpath.Cause
src/convert.jsreadsgeojson.properties[options.promoteId]with no guard against a null (or absent)properties.Fix
Guard the access.
null && x/undefined && xresolve to a falsy id, which is normalized to no id downstream (the same result as a missing property key), so behavior is unchanged for features that do have properties.Testing
Added a test that tiles a
properties: nullfeature withpromoteId. It throws on the current code and passes with the fix. The full suite stays green (29 tests).