Repository navigation
Fix GeoJsonTooltip/GeoJsonPopup on a single Feature or null properties - #2346
Open
kavyalavti wants to merge 1 commit into
Open
kavyalavti wants to merge 1 commit into
kavyalavti wants to merge 1 commit into
Conversation
GeoJsonDetail always read data["features"] and assumed the first feature's properties is a dict. GeoJson only converts its data to a FeatureCollection when styling is used, so a tooltip or popup on a single Feature raised KeyError, and null properties raised AttributeError. Read the features the same way convert_to_feature_collection interprets the data and treat null properties as empty. Fixes python-visualization#2345 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Problem
GeoJsonaccepts a singleFeatureor a bare geometry, butGeoJsonTooltipandGeoJsonPopupcrash on such a layer withKeyError: 'features'. A feature with"properties": null, which RFC 7946 allows, crashes withAttributeError.Reproduce
Fix
GeoJsononly converts its data to aFeatureCollectionwhenstyle_functionorhighlight_functionis given.GeoJsonDetailgains a small_geojson_features()helper that reads the features the same wayconvert_to_feature_collectioninterprets the data:FeatureCollectiongives its featuresFeaturegives a single featurerenderandwarn_for_geometry_collectionsuse it, andnullproperties count as an empty dict. Requested fields that don't exist still fail with the existing "The field ... is not available" assertion. This mirrors the earlier TopoJson fix covered bytest_topojson_non_collection_geometry_detail.Tests
test_geojson_single_feature_detailcovers popup and tooltip on a singleFeature, with properties and withnullproperties.test_geojson_geometry_detail_unknown_fieldchecks that a bare geometry gives the clean "not available" error instead ofKeyError.mainand pass with the fix.pytest tests --ignore=tests/selenium --ignore=tests/snapshots: 402 passed. The 3 failures intests/test_repr.pyneed a Chrome webdriver and fail onmainlocally too.AI disclosure: this change was prepared with the help of Claude Code (Anthropic). I reviewed the diff and test results.
Fixes #2345
🤖 Generated with Claude Code