Skip to content

[ipapi.is] fix error when some location field is invalid - #22493

Merged
raycastbot merged 2 commits into
raycast:mainfrom
xmok:ext/ipapi-is
Oct 29, 2025
Merged

raycastbot merged 2 commits into
raycast:mainfrom
xmok:ext/ipapi-is

Conversation

@xmok

@xmok xmok commented Oct 28, 2025

Copy link
Copy Markdown
Contributor

Description

Can't reproduce but extension issues gives a good idea so PR should close #22492.

Screencast

N/A

Checklist

@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: ipapi-is Issues related to the ipapi-is extension platform: macOS platform: Windows OP is author The OP of the PR is the author of the extension labels Oct 28, 2025
@raycastbot

ghost commented Oct 28, 2025

Copy link
Copy Markdown
Collaborator

Thank you for the update! 🎉

You can expect an initial review within five business days.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, and vpn.last_seen
  • Updated @raycast/api from 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

Edit Code Review Agent Settings | Greptile

@pernielsentikaer pernielsentikaer added Approved Approved by a user and removed Approved Approved by a user labels Oct 29, 2025
@raycastbot raycastbot added the Approved Approved by a user label Oct 29, 2025

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 treats 0 as 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 to number | undefined or 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

Edit Code Review Agent Settings | Greptile

Comment on lines +124 to +125
<Detail.Metadata.Label title="Latitude" text={`${data.location.latitude || "N/A"}`} />
<Detail.Metadata.Label title="Longitude" text={`${data.location.longitude || "N/A"}`} />

ghost Oct 29, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: using || will incorrectly display "N/A" for valid coordinates at 0 (equator/prime meridian). Use nullish coalescing instead

Suggested change
<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"}`} />

ghost Oct 29, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: using || will show "N/A" for valid unix timestamp 0 (Jan 1, 1970). Use nullish coalescing

Suggested change
<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"}`} />

ghost Oct 29, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

logic: using || will show "N/A" for valid unix timestamp 0. Use nullish coalescing

Suggested change
<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"}`} />

@pernielsentikaer pernielsentikaer self-assigned this Oct 29, 2025

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, approved 🔥

@raycastbot
raycastbot merged commit 6825a34 into raycast:main Oct 29, 2025
@github-actions

ghost commented Oct 29, 2025

Copy link
Copy Markdown
Contributor

@raycastbot

ghost commented Oct 29, 2025

Copy link
Copy Markdown
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

@xmok
xmok deleted the ext/ipapi-is branch November 2, 2025 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approved Approved by a user extension fix / improvement Label for PRs with extension's fix improvements extension: ipapi-is Issues related to the ipapi-is extension OP is author The OP of the PR is the author of the extension platform: macOS platform: Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ipapi.is] Crash when likely location.latitude or location.longitude or location.local_time_unix is missing or invalid

4 participants