fix: show location-not-found page for v2 view with Oymyakon fallback - #1244
Open
algojogacor wants to merge 1 commit into
Open
algojogacor wants to merge 1 commit into
algojogacor wants to merge 1 commit into
Conversation
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
Owner
|
Thank you for your contribution, but there are a few issues:
Would you like to wait until I implement it (soon), or would you prefer to try it yourself? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
LocationNotFoundandOriginalLocationfields todomain.LocationRoot 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 codemodels.go: New fields on Location structrenderer.go: Warning banner rendering for v2/v2d/v2n viewsVerified 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