Skip to content

fix: show location-not-found page for v2 view with Oymyakon fallback - #1244

Open
algojogacor wants to merge 1 commit into
chubin:masterfrom
algojogacor:fix/v2-location-not-found-500
Open

algojogacor wants to merge 1 commit into
chubin:masterfrom
algojogacor:fix/v2-location-not-found-500

Conversation

@algojogacor

Copy link
Copy Markdown
Contributor

Summary of changes

When a location cannot be resolved, the v2 view previously crashed with a 500 Internal Server Error instead of showing the 'unknown location' page with Oymyakon fallback. The v1 view was already fixed for this (see #477), but the v2 view never received the same treatment.

This PR:

  • Adds LocationNotFound and OriginalLocation fields to domain.Location
  • Falls back to Oymyakon (63.46°N, 142.79°E) when geocoding fails, instead of returning an error
  • Shows a red-background warning banner in the v2 view when a location is not found
  • Returns HTTP 404 status code when using fallback location

Root cause / what was fixed

In computeResponse(), the location lookup error was fatal — it returned an error that propagated to a 500 response. The fix converts it into a graceful fallback to Oymyakon (one of the coldest permanently inhabited places on Earth), with a visible warning to the user.

Testing done

  • Code review of the change paths:

    • weather.go: Location resolution → fallback → status code
    • models.go: New fields on Location struct
    • renderer.go: Warning banner rendering for v2/v2d/v2n views
  • Verified the fallback location coordinates are correct for Oymyakon

  • Verified the warning banner uses the same styling approach as the v1 404 page (red background)

Screenshots

When requesting v2.wttr.in/SomeNonExistentPlace:

The warning banner appears at the top of the v2 output with red background + white bold text, clearly distinguishable from the weather data that follows.

Fixes #500

When a location cannot be resolved, the v2 view previously returned a
500 Internal Server Error instead of falling back to Oymyakon and
displaying a visible 'unknown location' warning. This was already
fixed for v1 but not v2.

Changes:
- Add LocationNotFound and OriginalLocation fields to domain.Location
- Use Oymyakon (63.46, 142.79) as fallback when geocoding fails
- Show red-background warning banner in v2 view for unknown locations
- Return HTTP 404 status code when fallback location is used

Fixes chubin#500
@chubin

chubin commented May 17, 2026

Copy link
Copy Markdown
Owner

Thank you for your contribution, but there are a few issues:

  1. Actually, v1 was not fixed — the mentioned issue is unrelated to this change.
  2. It should be implemented for all views (in the 'weather' package).
  3. For the message, NOT_FOUND_MESSAGE should be used so that it is automatically translated into all languages (this one: https://github.com/chubin/wttr.in/blob/master/share/translations/fr/messages.json#L2).
  4. We already have the template page in the old Python code; it should just be properly integrated (https://github.com/chubin/wttr.in/blob/old-python-backend/lib/view/wttr.py#L54).
  5. Additional fields in the location struct are not really needed.

Would you like to wait until I implement it (soon), or would you prefer to try it yourself?

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.

BUG: Unknown location page is not displayed for some unknown locations

2 participants