Skip to content

fix: stabilize emulator location override fetch and logging#90

Open
mattrossman wants to merge 1 commit intomainfrom
fix/emulator-location-override
Open

fix: stabilize emulator location override fetch and logging#90
mattrossman wants to merge 1 commit intomainfrom
fix/emulator-location-override

Conversation

@mattrossman
Copy link
Copy Markdown
Owner

  • tighten location override parsing and reverse-geocode handling so text queries are handled correctly and missing address payloads do not crash PKJS.
  • add forceFetchOnBoot support in src/pkjs/dev-config.js processing so emulator boots can force an immediate weather fetch without opening settings.
  • document dev-config usage with an example location (New York, NY) and improve geocode log output readability.
    ref: support lat/long in override location and avoid location lookup #59

@github-actions
Copy link
Copy Markdown
Contributor

✅ Preview build available.

Download forecaswatch2-pbw-pr-90.zip

Artifacts are attached to the workflow run/job and require GitHub access to this repository.
Run: #14

@mattrossman mattrossman marked this pull request as ready for review February 22, 2026 07:26
@mattrossman mattrossman requested a review from Copilot February 22, 2026 07:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves developer/emulator ergonomics around location override and boot-time fetching, while hardening some geocoding/reverse-geocoding paths to avoid PKJS crashes or confusing logs.

Changes:

  • Harden reverse-geocode parsing and improve geocode logging readability.
  • Tighten lat/long override detection with a stricter regex.
  • Add forceFetchOnBoot handling for dev-config.js and document usage in the README.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/pkjs/weather/provider.js Adjusts reverse-geocode handling and location override parsing/logging.
src/pkjs/index.js Adds forceFetchOnBoot dev-config behavior by clearing lastFetchSuccess.
README.md Documents dev-config.js usage with location and forceFetchOnBoot example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

var address = JSON.parse(response).address;
var body = JSON.parse(response);
if (!body.address) {
console.log('[!] Reverse geocoding response had no address object');
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

If the reverse-geocode response has no address, this function returns without invoking callback, which will stall the whole fetch chain (fetch() waits on withCityName). Consider still calling callback with a safe fallback (e.g., empty/"Unknown") and/or propagating failure so the fetch can complete deterministically.

Suggested change
console.log('[!] Reverse geocoding response had no address object');
console.log('[!] Reverse geocoding response had no address object');
callback('Unknown');

Copilot uses AI. Check for mistakes.
Comment on lines 88 to 90
var url = 'https://us1.locationiq.com/v1/search.php?key=' + locationiq_key
+ '&q=' + this.location
+ '&q=' + locationQuery
+ '&format=json';
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

locationQuery is interpolated into the LocationIQ URL without URL-encoding. Queries like the README example ("New York, NY") contain spaces/comma and should be passed through encodeURIComponent to avoid malformed requests or unexpected server parsing.

Copilot uses AI. Check for mistakes.
Comment on lines 105 to 107
if (locations.length === 0) {
console.log('[!] No geocoding results')
}
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

When the geocoding API returns an empty result set (locations.length === 0), the code only logs and never calls callback, which can also stall the fetch flow. Consider invoking the callback with a failure signal/fallback coordinates so downstream logic can proceed or fail cleanly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@copilot is that related to this change tho

Copy link
Copy Markdown

Copilot AI commented Feb 22, 2026

@mattrossman I've opened a new pull request, #91, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants