Skip to content

block[weather]: fix place name geocoding for OpenWeatherMap#2266

Open
cdbrkfxrpt wants to merge 2 commits intogreshake:masterfrom
cdbrkfxrpt:master
Open

block[weather]: fix place name geocoding for OpenWeatherMap#2266
cdbrkfxrpt wants to merge 2 commits intogreshake:masterfrom
cdbrkfxrpt:master

Conversation

@cdbrkfxrpt
Copy link
Copy Markdown

Using query_pairs_mut().append_pair() to build the geo URL percent-encodes the comma in place names like "London,UK", turning it into "London%2CUK" and causing the request to 404. Build the query string directly instead to preserve the comma as-is.

While here, move get_location_query out of impl Service into a free function and resolve the API key from config internally rather than threading it through as a parameter. Add a trailing slash to GEO_URL so that Url::join works correctly with relative path segments. Add an ignored integration test for place name resolution.

Comment thread src/blocks/weather/open_weather_map.rs Outdated
@ammgws
Copy link
Copy Markdown
Collaborator

ammgws commented Apr 12, 2026

While here, move get_location_query out of impl Service into a free function and resolve the API key from config internally rather than threading it through as a parameter.

Can you please move this into a separate commit?

The OpenWeatherMap geo API expects literal commas in the `q` parameter
(e.g. "London,UK"), but `query_pairs_mut().append_pair()` percent-encodes
them into "%2C", causing the request to 404.

Build the query string with `format!` and `Url::join` instead, which
preserves the commas. Also add a trailing slash to `GEO_URL` so that
`join` resolves relative paths correctly.

Adds an `#[ignore]`d integration test that verifies place-based
geocoding against the live API.
Move `Service::get_location_query` out of the impl block into a
standalone async function. Use `api_key` from provided `Config`,
instead of needlessly taking it as a parameter.
@cdbrkfxrpt
Copy link
Copy Markdown
Author

While here, move get_location_query out of impl Service into a free function and resolve the API key from config internally rather than threading it through as a parameter.

Can you please move this into a separate commit?

done

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.

2 participants