Skip to content

fix(google-maps): validate integration against live API docs, add Places Nearby Search#5484

Merged
waleedlatif1 merged 3 commits into
stagingfrom
worktree-google-maps-validate
Jul 7, 2026
Merged

fix(google-maps): validate integration against live API docs, add Places Nearby Search#5484
waleedlatif1 merged 3 commits into
stagingfrom
worktree-google-maps-validate

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • validated the Google Maps integration against live API docs for all 12 covered Maps Platform APIs (Geocoding, Directions, Distance Matrix, Places, Elevation, Timezone, Roads, Geolocation, Address Validation, Solar, Air Quality, Pollen)
  • added google_maps_places_nearby tool (Places API New searchNearby) for radius/type-based place discovery — a distinct use case from the existing text-search tool, within the already-enabled Places API
  • added pageToken support to places_search for paginating text search results
  • added units param to speed_limits (KPH/MPH per Roads API)
  • wired homeMobileCountryCode/homeMobileNetworkCode subblocks for geolocate (existing tool params had no block inputs)
  • split the shared radius subblock so Nearby Search's required radius isn't buried in advanced mode while Text Search's stays optional/advanced
  • added a default value to the rankPreference dropdown
  • added the missing authMode: AuthMode.ApiKey on the block

Considered but not added (would need capabilities beyond this API key/JSON-output integration, not new API scopes): Place Photos (binary output, no blob-handling in this block) and Places Autocomplete (needs session-token billing semantics). Neither requires new API enablement, but both need architecture this integration doesn't have yet.

Type of Change

  • Bug fix
  • New feature (Places Nearby Search)

Testing

Tested manually. bun run lint and typecheck pass clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…ces Nearby Search

- add google_maps_places_nearby tool (Places API New, searchNearby) for radius/type-based place discovery
- add pageToken support to places_search (text search pagination)
- add units param to speed_limits (Roads API KPH/MPH)
- wire homeMobileCountryCode/homeMobileNetworkCode subblocks for geolocate
- split radius subblock so places_nearby's required radius isn't hidden in advanced mode
- add default value to rankPreference dropdown
- add missing authMode: AuthMode.ApiKey on the block
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 7, 2026 6:41pm

Request Review

@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes extend an existing integration with new optional APIs and form wiring; no auth or core execution path refactors. Hosted-key behavior for speed limits is unchanged (BYOK only).

Overview
Adds Nearby Places as a new Google Maps block operation backed by a google_maps_places_nearby tool (Places API searchNearby), with required radius, optional type filter, max results, rank preference, and region/language fields wired through the block and registry.

Places text search gains pageToken support for pagination. Speed limits exposes KPH/MPH via a dedicated speedUnits subblock mapped to the Roads API units param. Geolocate gets block inputs for home MCC/MNC that were already supported on the tool.

The block sets authMode: ApiKey, tightens numeric parsing for radius and related fields, scopes the shared Language field to relevant operations, and adds a find-places-nearby skill template. Elevation treats missing resolution as optional/null in types and output.

Reviewed by Cursor Bugbot for commit 4a680f3. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR validates the Google Maps block against live API docs, adds a new google_maps_places_nearby tool (Places API New searchNearby), and wires several previously unconnected parameters such as homeMobileCountryCode/homeMobileNetworkCode for geolocate and units for speed limits.

  • New tool: places_nearby.ts implements a full Places API New searchNearby POST request with correct X-Goog-FieldMask header, proper body construction, and safe transformResponse handling.
  • Block fixes: Adds authMode: AuthMode.ApiKey, pageToken for text-search pagination (with timing caveat in description), speedUnits dropdown, and NaN-safe parsing for radius, maxResultCount, homeMobileCountryCode, and homeMobileNetworkCode.
  • Parameter routing: placeType is mapped to both type (for the legacy text-search tool) and includedTypes array (for the new nearby tool) in a single transform return, correctly isolating the two APIs.

Confidence Score: 4/5

Safe to merge for all new tool functionality; a pre-existing structural concern in the block's subblock list warrants a follow-up.

All seven tool files (new and modified) are correct: request construction, header handling, response transforms, and type definitions are well-formed. The block transform correctly parses string inputs to the expected number types with NaN guards throughout. The one open concern — two subblock entries sharing id: 'radius' with different required/mode metadata — was noted in a prior review round and remains unresolved; if the block rendering or form-state layer keys on id, the places_nearby radius field could silently inherit the places_search variant's mode: 'advanced' and non-required metadata, bypassing the intended UI guard for the mandatory field.

apps/sim/blocks/blocks/google_maps.ts — the duplicate radius subblock definition.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/google_maps.ts Adds Nearby Places operation, wires new params, fixes NaN guards, and adds authMode — but retains two subblocks sharing id: 'radius' (one for places_search, one for places_nearby) which may cause undefined behaviour in block state tracking.
apps/sim/tools/google_maps/places_nearby.ts New tool correctly implements the Places API New searchNearby endpoint; request body, headers, field mask, and response transform are all well-formed.
apps/sim/tools/google_maps/places_search.ts Adds pageToken query param (lowercase pagetoken as required by the legacy API) with appropriate timing note in the description.
apps/sim/tools/google_maps/speed_limits.ts Adds units query param (KPH/MPH) correctly forwarded to the Roads API speedLimits endpoint.
apps/sim/tools/google_maps/elevation.ts Marks resolution as optional and coalesces undefined to null in the response, consistent with the API's documented behaviour for path-based requests.
apps/sim/tools/google_maps/types.ts Adds NearbyPlaceResult, GoogleMapsPlacesNearbyParams/Response, pageToken to places search params, units to speed limits params — all aligned with their respective tool implementations.
apps/sim/tools/registry.ts Registers google_maps_places_nearby in the tool registry — straightforward one-liner addition.
apps/sim/tools/google_maps/index.ts Re-exports googleMapsPlacesNearbyTool alongside existing exports — no issues.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant UI as Block UI
    participant Block as google_maps.ts (transform)
    participant Registry as Tool Registry
    participant NearbyTool as places_nearby.ts
    participant GoogAPI as Places API (New)

    UI->>Block: "operation=places_nearby, aqLatitude, aqLongitude, radius, placeType, rankPreference, maxResultCount"
    Note over Block: Parses aqLatitude→lat, aqLongitude→lng,<br/>radius→parseInt, maxResultCount→parseInt,<br/>placeType→includedTypes[]
    Block->>Registry: "tool=google_maps_places_nearby, {lat, lng, radius, includedTypes, rankPreference, ...}"
    Registry->>NearbyTool: invoke with merged params
    NearbyTool->>GoogAPI: "POST /v1/places:searchNearby<br/>X-Goog-Api-Key, X-Goog-FieldMask<br/>body: {locationRestriction:{circle:{center,radius}}, includedTypes, rankPreference, ...}"
    GoogAPI-->>NearbyTool: "{places:[{id, displayName, formattedAddress, location, rating, ...}]}"
    NearbyTool-->>Registry: "{success:true, output:{places:[{placeId, name, lat, lng, rating, ...}]}}"
    Registry-->>UI: output.places
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant UI as Block UI
    participant Block as google_maps.ts (transform)
    participant Registry as Tool Registry
    participant NearbyTool as places_nearby.ts
    participant GoogAPI as Places API (New)

    UI->>Block: "operation=places_nearby, aqLatitude, aqLongitude, radius, placeType, rankPreference, maxResultCount"
    Note over Block: Parses aqLatitude→lat, aqLongitude→lng,<br/>radius→parseInt, maxResultCount→parseInt,<br/>placeType→includedTypes[]
    Block->>Registry: "tool=google_maps_places_nearby, {lat, lng, radius, includedTypes, rankPreference, ...}"
    Registry->>NearbyTool: invoke with merged params
    NearbyTool->>GoogAPI: "POST /v1/places:searchNearby<br/>X-Goog-Api-Key, X-Goog-FieldMask<br/>body: {locationRestriction:{circle:{center,radius}}, includedTypes, rankPreference, ...}"
    GoogAPI-->>NearbyTool: "{places:[{id, displayName, formattedAddress, location, rating, ...}]}"
    NearbyTool-->>Registry: "{success:true, output:{places:[{placeId, name, lat, lng, rating, ...}]}}"
    Registry-->>UI: output.places
Loading

Reviews (5): Last reviewed commit: "fix(google-maps): guard radius NaN parse..." | Re-trigger Greptile

Comment thread apps/sim/tools/google_maps/places_search.ts
Google's Elevation API omits resolution when it can't be determined,
but our output schema declared it as a required number. Also fixes a
stale comment calling Speed Limits "deprecated" when it's actually
Asset Tracking-license restricted.
- radius parsing in transformParams now guards NaN like every other
  numeric param in this block, so a non-numeric radius no longer
  silently sends "radius":null to the required Nearby Search field
- pageToken description/placeholder now note the required delay
  before a token becomes valid, per Places Text Search API behavior
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Responding to Greptile's two "Comments Outside Diff" findings from the last review round:

  1. Missing Number.isNaN guard on radius — fixed in 4a680f3. radius now guards NaN the same way days/maxResultCount/homeMobileCountryCode/homeMobileNetworkCode already do in this file, so a non-numeric radius no longer silently sends "radius":null to the required Nearby Search field.

  2. Duplicate subblock id: 'radius' — verified this is a safe, established pattern already used elsewhere in this exact file (the pre-existing apiKey subblock is split the same way across two mutually-exclusive conditions), and in 9+ other blocks in the codebase (datagma, exa, firecrawl, leadmagic, image_generator, findymail, millionverifier, mistral_parse, vision). The conditions are collectively exhaustive and mutually exclusive per operation, so only one variant is ever visible/active at a time — no undefined behavior. No change made; keeping this consistent with the rest of the codebase.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/tools/google_maps/places_nearby.ts
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

Follow-up on the outstanding `radius` duplicate-id question (previous reply cited cross-block precedent; here's the code-level proof).

Traced the actual rendering path: `apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/hooks/use-editor-subblock-layout.ts:117` computes `visibleSubBlocks` via a plain array `.filter()` over `config.subBlocks`, evaluating each entry's `condition` against the current `operation` value (line 149-151, `evaluateSubBlockCondition`). This is not a `Record`/`Map` keyed by `id` — there is no dedup-by-key step anywhere in this path. Since the two `radius` entries have mutually exclusive conditions (`operation: 'places_search'` vs `operation: 'places_nearby'`), at most one can ever pass the filter for a given operation value, so `visibleSubBlocks` never contains two entries with the same `id` simultaneously — there's no scenario where the wrong variant's `required`/`mode` metadata could apply.

This confirms it structurally, not just by precedent: the pattern is safe by construction. No change made.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 4a680f3. Configure here.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile this exact concern was already addressed with code-level proof — see the reply at #5484 (comment) above, which traces the actual render path in apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/hooks/use-editor-subblock-layout.ts:117. visibleSubBlocks is computed via a plain array .filter() (not a Record/Map keyed by id), and the two radius entries have mutually exclusive conditions on operation, so at most one is ever in the filtered array for a given operation. There is no id-keyed collapse anywhere in that path, so the required-field metadata for places_nearby's radius cannot be silently clobbered. Please re-review with this in mind.

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1 waleedlatif1 merged commit 98dc1ee into staging Jul 7, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the worktree-google-maps-validate branch July 7, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant