feat(geo): use server-verified location from PUT response#1051
Closed
feat(geo): use server-verified location from PUT response#1051
Conversation
When the geoloc service crosschecks a suspicious location via a verification provider and obtains a better result, it now returns the corrected geolocation in the PUT response body. This change makes the agent prefer that server-verified location over the original one obtained from the external provider, so the current session benefits from the correction immediately instead of only future queries.
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
The geoloc service recently added a location crosscheck feature: when a device submits a suspicious location via the WiFi strategy (poor accuracy or large distance jump from previous known position), the service re-queries a verification provider (e.g. Google Geolocation) to get a corrected result.
However, the corrected location was only persisted server-side — the agent continued using the original (potentially incorrect) location for the current session because it never read the PUT response body.
This change makes the agent check the PUT
/georesponse body for a server-verified location. When the geoloc service returns a corrected geolocation, the agent uses it instead of the original, so the current session benefits from the correction immediately.What changed
strategies.js: Theneedle.putcallback now captures the response (respPut) and checks ifrespPut.body.locationexists. If present, it uses the server-verified location; otherwise, it falls back to the original geolocation from the external provider.Backward compatible
null(current behavior for unverified locations),respPut.body.locationis falsy, so the agent falls back to the original location — no behavior change.Test plan
nullin the PUT response, the agent uses the original external provider location (no regression)