Skip to content

fix: expect text/plain MIME type from wttr.in API reponses#70

Merged
null8626 merged 1 commit intonull8626:mainfrom
Koloss0:fix/client-get-raising-error
Apr 29, 2026
Merged

fix: expect text/plain MIME type from wttr.in API reponses#70
null8626 merged 1 commit intonull8626:mainfrom
Koloss0:fix/client-get-raising-error

Conversation

@Koloss0
Copy link
Copy Markdown
Contributor

@Koloss0 Koloss0 commented Apr 28, 2026

The MIME type of the responses from wttr.in seems to have changed to text/plain for some reason which caused Client.get() to fail 100% of the time, returning the following stack trace:

Traceback (most recent call last):
  File "/home/pi/dev/python/weather-test/main.py", line 9, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/pi/dev/python/weather-test/main.py", line 5, in main
    weather = await client.get("Winnipeg")
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/dev/python/python-weather/python_weather/client.py", line 190, in get
    raise RequestError(status, reason) from None
python_weather.errors.RequestError: 200: OK

The fix was as simple as changing the expected value application/text to text/plain in the call to resp.json().

All tests pass with PyTest:

$ pytest
============================================================================================================ test session starts =============================================================================================================
platform linux -- Python 3.11.2, pytest-9.0.3, pluggy-1.6.0
rootdir: /home/pi/dev/python/python-weather
configfile: pyproject.toml
plugins: cov-7.1.0, asyncio-1.3.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1298 items                                                                                                                                                                                                                         

test_client.py ............................................                                                                                                                                                                            [  3%]
test_enums.py ........................................................................................................................................................................................................................ [ 20%]
...................................................................................................................................................................................................................................... [ 37%]
...................................................................................................................................................................................................................................... [ 55%]
...................................................................................................................................................................................................................................... [ 73%]
...................................................................................................................................................................................................................................... [ 90%]
......................................................................................................................                                                                                                                 [100%]

=========================================================================================================== 1298 passed in 15.73s ============================================================================================================

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown
Owner

@null8626 null8626 left a comment

Choose a reason for hiding this comment

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

Thank you so much for this! <3

Merging and immediately issuing a new patch release.

@null8626 null8626 merged commit c47b63f into null8626:main Apr 29, 2026
1 check passed
@null8626
Copy link
Copy Markdown
Owner

Fix published under v2.2.1! ❤️

This was referenced Apr 29, 2026
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