Skip to content

lib: fix incorrect backend detection in get_backend()#7240

Open
Photon079 wants to merge 1 commit intoOSGeo:mainfrom
Photon079:fix/get-backend-bug
Open

lib: fix incorrect backend detection in get_backend()#7240
Photon079 wants to merge 1 commit intoOSGeo:mainfrom
Photon079:fix/get-backend-bug

Conversation

@Photon079
Copy link
Copy Markdown

Previously, get_backend() returned "ipyleaflet" when folium import failed, without validating whether the object was actually an ipyleaflet.Map. This could lead to incorrect backend selection and failures in layer operations.

This fix:

  • Properly checks object types for both folium and ipyleaflet
  • Raises clear ValueError when neither backend matches
  • Adds comprehensive tests covering all edge cases
  • Follows GRASS coding standards

This issue was discovered while writing tests for grass.jupyter as part of the GSoC test-of-skills tasks. I have also opened issue #7239 for tracking this bug.

Previously, get_backend() would return 'ipyleaflet' whenever folium import
failed, without checking if the object was an ipyleaflet.Map.
This could cause crashes in Layer.add_to() methods when wrong backend
was selected.

This fix:
- Properly checks object types for both folium and ipyleaflet
- Raises clear ValueError when neither backend matches
- Adds comprehensive tests covering all edge cases
- Follows GRASS coding standards

Bug discovered while writing tests - original logic made dangerous
assumptions that could break map functionality.

AI assistance used for codebase understanding and test design.
All code changes and testing were performed by the contributor.
@Photon079 Photon079 changed the title Fix incorrect backend detection in get_backend() when imports fail python.jupyter: fix incorrect backend detection in get_backend() Mar 30, 2026
@github-actions github-actions bot added Python Related code is in Python libraries tests Related to Test Suite notebook labels Mar 30, 2026
@Photon079 Photon079 changed the title python.jupyter: fix incorrect backend detection in get_backend() lib: fix incorrect backend detection in get_backend() Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries notebook Python Related code is in Python tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant