Skip to content

Commit 53fe0d3

Browse files
committed
fix(google_maps): guard !response.ok in Pollen/Solar; use ?? for color channels
Address Greptile review: - Pollen and Solar transformResponse now check !response.ok || data.error (matches the Custom Search fix); a gateway error without an error key in the body no longer returns empty/zeroed output silently. - Pollen color channels use ?? instead of || so a legitimate 0 isn't treated as missing (consistent with the other numeric fields in the file).
1 parent 53d675a commit 53fe0d3

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

apps/sim/tools/google_maps/pollen.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ const mapIndexInfo = (indexInfo: RawIndexInfo | undefined) =>
1919
category: indexInfo.category || '',
2020
indexDescription: indexInfo.indexDescription || '',
2121
color: {
22-
red: indexInfo.color?.red || 0,
23-
green: indexInfo.color?.green || 0,
24-
blue: indexInfo.color?.blue || 0,
22+
red: indexInfo.color?.red ?? 0,
23+
green: indexInfo.color?.green ?? 0,
24+
blue: indexInfo.color?.blue ?? 0,
2525
},
2626
}
2727
: null
@@ -109,8 +109,8 @@ export const googleMapsPollenTool: ToolConfig<GoogleMapsPollenParams, GoogleMaps
109109
transformResponse: async (response: Response) => {
110110
const data = await response.json()
111111

112-
if (data.error) {
113-
throw new Error(`Pollen lookup failed: ${data.error.message || 'Unknown error'}`)
112+
if (!response.ok || data.error) {
113+
throw new Error(`Pollen lookup failed: ${data.error?.message || response.statusText}`)
114114
}
115115

116116
const dailyInfo = (data.dailyInfo || []).map(

apps/sim/tools/google_maps/solar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export const googleMapsSolarTool: ToolConfig<GoogleMapsSolarParams, GoogleMapsSo
6868
transformResponse: async (response: Response) => {
6969
const data = await response.json()
7070

71-
if (data.error) {
72-
throw new Error(`Solar lookup failed: ${data.error.message || 'Unknown error'}`)
71+
if (!response.ok || data.error) {
72+
throw new Error(`Solar lookup failed: ${data.error?.message || response.statusText}`)
7373
}
7474

7575
const potential = data.solarPotential

0 commit comments

Comments
 (0)