adafruit / adafruit/Adafruit_CircuitPython_PyPortal

Handle failure from image converter service or other HttpErrors in `wget()`

Open
#128 44 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
46
Forks
56
PR merge metrics
No merged PRs in 30d

Description

If `wget()` in PortalBase `(https://github.com/adafruit/Adafruit_CircuitPython_PortalBase/blob/7a3277af2efb804c7ecf82d8bc87eb95c22dee2e/adafruit_portalbase/network.py#L319) gets some kind of HTTP error, it will raise `adafruit_portalbase.network.HttpError`, which is a subclass of `Exception`.

This exception is not handled when `wget()` is called here:
https://github.com/adafruit/Adafruit_CircuitPython_PyPortal/blob/a14d41bff67ec9411e8c7b5b9b8425ff39dae807/adafruit_pyportal/network.py#L191-L196.

A scenario where this happened is described in the forums [here](https://forums.adafruit.com/viewtopic.php?t=204689): the Cleveland Museum of Art may return image URL's that return 404's. These cause the image converter service to return a 422.

I'm thinking that maybe PortalBase should return an easier-to-catch exception, or PyPortal should catch that HttpError and turn it into something else.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with adafruit_portalbase/network.py around wget() at line 319, then inspect adafruit_pyportal/network.py around lines 191-196 where it is called. Trace the HttpError raised for HTTP failures such as the described 404-to-422 case and decide which layer should handle or translate it. Done means the converter failure no longer escapes as an unhandled exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.