Repository navigation
[ipapi.is] fix error when some location field is invalid - #22493
Conversation
commented
Oct 28, 2025
|
Thank you for the update! 🎉 You can expect an initial review within five business days. |
left a comment
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Fixed crash when API returns missing or invalid location fields (latitude, longitude, local_time_unix) and VPN last_seen field by adding fallback to "N/A" string.
Key changes:
- Changed
.toString()calls to template literals with nullish fallback:`${value || "N/A"}` - Applied fix to 4 fields:
latitude,longitude,local_time_unix, andvpn.last_seen - Updated
@raycast/apifrom 1.103.2 to 1.103.5 - Added CHANGELOG entry referencing issue #22492
Issue: Type definitions in types.ts:52-57 declare these fields as non-optional number, but runtime code now treats them as potentially falsy. This creates a type mismatch that TypeScript won't catch.
Confidence Score: 3/5
- This PR fixes a real crash but has a type safety issue that should be addressed
- The fix prevents the crash, but there's a mismatch between type definitions (which declare fields as non-optional numbers) and the runtime handling (which treats them as potentially undefined). This means the types don't accurately reflect reality, which could cause issues elsewhere in the codebase
- Pay attention to
types.ts- type definitions should be updated to match the actual API behavior
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| extensions/ipapi-is/src/lookup-ip-or-asn.tsx | 4/5 | Fixed crash by safely handling missing/invalid latitude, longitude, local_time_unix, and last_seen values with fallback to "N/A" |
| extensions/ipapi-is/CHANGELOG.md | 5/5 | Added changelog entry documenting the fix for missing location fields with proper issue reference |
3 files reviewed, 1 comment
left a comment
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
Attempted to fix crashes when API returns missing/invalid location fields by adding fallback handling for latitude, longitude, local_time_unix, and last_seen fields.
Critical Issue Found:
- Uses logical OR (
||) instead of nullish coalescing (??) for numeric fields, which incorrectly treats0as falsy - Coordinates at 0,0 (equator/prime meridian) would display as "N/A" instead of valid values
- Unix timestamp 0 (Jan 1, 1970) would also show as "N/A"
Additional Concern:
- The TypeScript types define these fields as non-nullable
number, but the code now handles them as potentially missing. Either the types should be updated tonumber | undefinedor the API contract should be verified to ensure these are always present.
Confidence Score: 2/5
- PR introduces new bugs while attempting to fix crashes - valid zero values will be incorrectly displayed
- The fix uses
||operator which treats 0 as falsy, causing valid geographic coordinates of 0 (equator/prime meridian) and unix timestamp 0 to incorrectly display as "N/A". This creates new bugs while fixing the original crash issue. The approach is correct but needs to use??instead of||. - extensions/ipapi-is/src/lookup-ip-or-asn.tsx requires fixing the operator from
||to??on lines 124, 125, 129, and 145
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| extensions/ipapi-is/src/lookup-ip-or-asn.tsx | 2/5 | Added defensive null handling for numeric location/VPN fields, but uses ` |
3 files reviewed, 3 comments
| <Detail.Metadata.Label title="Latitude" text={`${data.location.latitude || "N/A"}`} /> | ||
| <Detail.Metadata.Label title="Longitude" text={`${data.location.longitude || "N/A"}`} /> |
There was a problem hiding this comment.
logic: using || will incorrectly display "N/A" for valid coordinates at 0 (equator/prime meridian). Use nullish coalescing instead
| <Detail.Metadata.Label title="Latitude" text={`${data.location.latitude || "N/A"}`} /> | |
| <Detail.Metadata.Label title="Longitude" text={`${data.location.longitude || "N/A"}`} /> | |
| <Detail.Metadata.Label title="Latitude" text={`${data.location.latitude ?? "N/A"}`} /> | |
| <Detail.Metadata.Label title="Longitude" text={`${data.location.longitude ?? "N/A"}`} /> |
| <Detail.Metadata.Label title="Timezone" text={data.location.timezone} /> | ||
| <Detail.Metadata.Label title="Local Time" text={data.location.local_time} /> | ||
| <Detail.Metadata.Label title="Local Time (UNIX)" text={data.location.local_time_unix.toString()} /> | ||
| <Detail.Metadata.Label title="Local Time (UNIX)" text={`${data.location.local_time_unix || "N/A"}`} /> |
There was a problem hiding this comment.
logic: using || will show "N/A" for valid unix timestamp 0 (Jan 1, 1970). Use nullish coalescing
| <Detail.Metadata.Label title="Local Time (UNIX)" text={`${data.location.local_time_unix || "N/A"}`} /> | |
| <Detail.Metadata.Label title="Local Time (UNIX)" text={`${data.location.local_time_unix ?? "N/A"}`} /> |
| <> | ||
| <Detail.Metadata.Label title="Region" text={data.vpn.region} /> | ||
| <Detail.Metadata.Label title="Last Seen" text={data.vpn.last_seen.toString()} /> | ||
| <Detail.Metadata.Label title="Last Seen" text={`${data.vpn.last_seen || "N/A"}`} /> |
There was a problem hiding this comment.
logic: using || will show "N/A" for valid unix timestamp 0. Use nullish coalescing
| <Detail.Metadata.Label title="Last Seen" text={`${data.vpn.last_seen || "N/A"}`} /> | |
| <Detail.Metadata.Label title="Last Seen" text={`${data.vpn.last_seen ?? "N/A"}`} /> |
commented
Oct 29, 2025
|
Published to the Raycast Store: |
commented
Oct 29, 2025
|
🎉 🎉 🎉 We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag. |
Description
Can't reproduce but extension issues gives a good idea so PR should close #22492.
Screencast
N/A
Checklist
npm run buildand tested this distribution build in Raycastassetsfolder are used by the extension itselfREADMEare located outside the metadata folder if they were not generated with our metadata tool