fix(drivingDistance): raise error on negative distance input#3105
Open
aki1770-del wants to merge 1 commit intopgRouting:mainfrom
Open
fix(drivingDistance): raise error on negative distance input#3105aki1770-del wants to merge 1 commit intopgRouting:mainfrom
aki1770-del wants to merge 1 commit intopgRouting:mainfrom
Conversation
…ng#3091) pgr_drivingDistance and pgr_drivingDistanceWithPoints silently returned an empty result set when called with a negative distance value. This was indistinguishable from a valid empty-graph result, masking routing configuration bugs. Fix: add a negative-distance guard in both drivers before graph query execution, consistent with the validation already present in develop branch (src/spanningTree/spanningTree_process.cpp:105-106). Adds pgTap regression test in edge_cases/issue_3091.pg. Fixes pgRouting#3091 Co-Authored-By: Claude and aki1770-del <aki1770@gmail.com>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Summary
pgr_drivingDistanceandpgr_drivingDistanceWithPointssilently returned an empty result set when called with a negativedistancevalue. An empty result is indistinguishable from a valid empty-graph result — callers have no way to detect the misconfiguration.The
developbranch (4.1.0-dev) already raisesERROR: Negative value found on 'distance'viasrc/spanningTree/spanningTree_process.cpp:105-106. This PR backports the equivalent guard tomain.Fix
Added a negative-distance guard in
pgr_do_drivingDistanceandpgr_do_drivingDistanceWithPoints(both C++ drivers) before graph query execution:Existing behavior audit (OPS-RULE-016)
src/driving_distance/driving_distance_driver.cpp: no distance validation before graph construction; negative values silently traverse an empty Dijkstra resultsrc/driving_distance/driving_distance_withPoints_driver.cpp: same pattern, same missing guardsrc/spanningTree/spanningTree_process.cpp(develop branch, line 105-106): contains the fix; does not exist onmainScope classification (OPS-RULE-017)
(a) Bug fix — missing input validation that causes silent incorrect behavior.
Prior art consulted (OPS-RULE-018)
developbranchsrc/spanningTree/spanningTree_process.cpp:82-106— the exact validation pattern this fix mirrors for themainbranchpgtap/dijkstra/driving_distance/edge_cases/issue_519.pg— existing edge-case test pattern followed for the newissue_3091.pgtestTest evidence
Added
pgtap/dijkstra/driving_distance/edge_cases/issue_3091.pg:throws_okfordistance = -1.0distance = 0.0returns only the origin node (valid edge case)AI-assisted — authored with Claude, reviewed by Komada.