Skip to content

Return 502 when Open-Meteo fails in the weather forecast endpoint - #743

Merged
marcvergees merged 2 commits into
fireform-core:developmentfrom
1sakshm:742-weather-upstream-502
Oct 25, 2026
Merged

marcvergees merged 2 commits into
fireform-core:developmentfrom
1sakshm:742-weather-upstream-502

Conversation

@1sakshm

@1sakshm 1sakshm commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Description

Follow-up to #731/#732. When Open-Meteo itself failed (down, 429 rate limit, or no network), GET /weather/forecast returned 500 INTERNAL_ERROR, the same code as a crash inside FireForm.

openmeteo_requests wraps every upstream failure in OpenMeteoRequestsError, so the route now catches it before the generic handler:

Situation Before After
Open-Meteo error / unreachable 500 INTERNAL_ERROR 502 WEATHER_FETCH_FAILED (message kept)
Any other exception 500 500 (unchanged)

This matches how the address lookup reports Nominatim failures (#741). No frontend change needed: the weather modal already shows the backend's message.

Fixes #742

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Added to TestWeatherEndpoints in tests/test_api.py:
    • test_forecast_upstream_error_is_502: openmeteo_requests.Client.weather_api raises OpenMeteoRequestsError → 502 WEATHER_FETCH_FAILED with the original message. Fails on development (500).
    • test_forecast_unexpected_error_is_500: any other exception still gives 500.
  • Full suite: python -m pytest tests/ → 315 passed
  • ruff check app/ → all checks passed

Test Configuration:

  • Python version: 3.11
  • Docker/Compose version: N/A (tests run locally)
  • OS: Windows 11

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • The Lint workflow check passes on this PR ✅
  • The Tests workflow check passes on this PR ✅

Upstream failures from openmeteo_requests (HTTP errors, rate limits,
no network) are now reported as 502 WEATHER_FETCH_FAILED instead of
500 INTERNAL_ERROR.

Fixes fireform-core#742
@marcvergees
marcvergees merged commit 5f5b1d0 into fireform-core:development Oct 25, 2026
2 checks passed
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]: Weather forecast returns 500 when Open-Meteo is unavailable

2 participants