Repository navigation
Fix BFS crash for unreachable goal and start equal to goal (fixes #1502) - #1505
Open
blessedefe4real wants to merge 1 commit into
Open
blessedefe4real wants to merge 1 commit into
blessedefe4real wants to merge 1 commit into
Conversation
BreadthFirstSearchPlanner.planning raised KeyError(-1) in two cases: - the goal cannot be reached: the loop broke out on an empty open set and calc_final_path looked up the goal's parent index -1; - the start is the goal: the goal is found immediately with parent index -1, causing the same lookup. Return empty lists when the open set is exhausted, and treat a missing parent as the start of the path. Add regression tests for both cases.
blessedefe4real
force-pushed
the
fix/bfs-unreachable-and-start-goal
branch
from
November 6, 2026 21:19
2026466 to
c20f1d4
Compare
1 of 3 tasks
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.
Reference issue
Fixes #1502
What does this implement/fix?
BreadthFirstSearchPlanner.planningraisedKeyError: -1when the goal is unreachable and when the start equals the goal, becausecalc_final_pathlooked upclosedset[ngoal.parent_index]while the goal's parent index was still-1.[], []when the open set is exhausted (same behavior as the Dijkstra fix proposed in Fix Dijkstra failure when goal is unreachable #1418), and document it in theplanningdocstring.calc_final_path, useclosedset.get(ngoal.parent_index)so a goal without a parent (start == goal) gives the single-point path.Normal planning is unchanged:
main()produces the same path.Additional information
Added
test_unreachable_goal_returns_empty_pathandtest_start_equal_to_goal_returns_single_point_pathtotests/test_breadth_first_search.py. Both raiseKeyError: -1onmasterand pass with this change. Full suite (pytest tests -Werror, as inruntests.sh): 158 passed;ruff checkpasses on the changed files.CheckList