Skip to content

pathfinding: validate inputs and cap waypoints#1440

Merged
brendancol merged 1 commit intomainfrom
issue-1439
May 4, 2026
Merged

pathfinding: validate inputs and cap waypoints#1440
brendancol merged 1 commit intomainfrom
issue-1439

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

@brendancol brendancol commented May 3, 2026

Closes #1439.

Summary

  • a_star_search and multi_stop_search now call _validate_raster on surface and on friction (when supplied).
  • multi_stop_search enforces _MAX_WAYPOINTS = 1000. The optimize_order path is O(N^3) so unbounded N is a CPU DoS.

Test plan

  • 5 new tests in TestPathfindingInputValidation.
  • pytest xrspatial/tests/test_pathfinding.py — 51 passed (46 existing + 5 new).
  • CI run on full suite.

a_star_search and multi_stop_search previously checked only
surface.ndim != 2.  Non-DataArray surfaces, complex dtypes, and
non-DataArray friction failed inside numba with confusing errors.

multi_stop_search did not bound len(waypoints).  The optimize_order
path is O(N^3) so unbounded N is a CPU DoS.

- Add _validate_raster on surface and (when supplied) friction.
- Add _MAX_WAYPOINTS = 1000 cap with a clear ValueError message.

5 new tests in TestPathfindingInputValidation.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 3, 2026
brendancol added a commit that referenced this pull request May 3, 2026
Records the 11 PRs filed this round:
- hydro: HIGH flow_direction_mfd memory guard (PR #1424); MEDIUM
  bundles for _validate_raster on secondary args (#1426), scalar
  param validation (#1428), and cellsize validation (#1430).
- reproject: MEDIUM bundles for _validate_raster (#1432), grid/bounds/
  precision validation (#1434), and NaN/Inf rejection (#1436).
- flood: mannings_n DataArray validation (#1438).
- pathfinding: waypoint cap + _validate_raster (#1440).
- polygonize: _validate_raster (#1442).
- terrain: scratch memory guard + scalar validation (#1444).
@brendancol brendancol merged commit 7d807c6 into main May 4, 2026
11 checks passed
@brendancol brendancol deleted the issue-1439 branch May 4, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pathfinding: missing _validate_raster on surface; multi_stop_search uncapped waypoints

1 participant