fix: reject out-of-range coordinates in Google text-search proxy - #46
Open
prajwal-raj wants to merge 1 commit into
Open
fix: reject out-of-range coordinates in Google text-search proxy#46prajwal-raj wants to merge 1 commit into
prajwal-raj wants to merge 1 commit into
Conversation
/api/google/text-search only checked that lat and lon were finite, not that they fell in valid ranges. Out-of-range values were forwarded straight to the Google Places request, spending quota on input that can never resolve. Reject latitude outside [-90, 90] or longitude outside [-180, 180] with a 400 before the upstream call. Refs bilawalsidhu#19
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.
/api/google/text-search validated that lat and lon were finite, but not that
they were actual coordinates. Anything finite got forwarded to Google Places,
so an out-of-range value spent quota on a request that could never return a
useful result.
This adds a bounds check right after the existing finite check: latitude has
to be within [-90, 90] and longitude within [-180, 180], otherwise the route
returns 400 before contacting Google. Valid coordinates are unaffected.
Scope note: issue #19 also mentions auth and rate limits for exposed use.
That is a broader concern shared across the other Google and OpenAI proxy
routes (#16, #17, #18), so I kept this PR to the coordinate-validation half,
which is the self-contained correctness fix. Using Refs rather than Closes so
the auth part can stay tracked.
Refs #19
Testing
failure is the pre-existing ground-3d probe tracked in test:track: ground-3d probe expects 4 sampleHeight calls but only makes 3 (fails on clean main) #44, unrelated to this
change and reproducible on a clean main.
and lon within [-180, 180]", with no upstream call made.
as before.