andreahlert opened a new pull request, #240:
URL: https://github.com/apache/airflow-steward/pull/240
## What
`api_get` was the only `urllib.request.urlopen` call in the `oauth-draft`
package without a `try/except urllib.error.HTTPError`. `api_post`, both calls
in `mark_threads_read`, and the token refresh in `credentials.py` all wrap the
call and raise `SystemExit` with a one-line `"Gmail API <path> failed (<code>):
<body>"` message.
### Impact
`api_get` is the path that `latest_reply_headers` uses, so any 401 / 403 /
404 from `GET /threads/{id}?format=full` (token expired, thread missing,
missing scope) surfaced as a raw Python traceback instead of the clean error
the rest of the tool produces. That path is exercised on every
`oauth-draft-create --thread-id <X>` invocation that does not pass
`--no-reply-headers`.
### Fix
Wraps `api_get` with the same handler as `api_post` and adds a regression
test mirroring `test_api_post_raises_on_http_error`.
## Changes
- `src/oauth_draft/create_draft.py` — `api_get` wrapped with `try/except
urllib.error.HTTPError`
- `tests/test_create_draft.py` — regression test asserting `api_get` raises
`SystemExit` with the `failed (<code>)` shape on a Gmail 404
## Validation
- `pytest`: 59 passed
- `ruff check` / `ruff format` / `mypy`: clean
- `prek`: all hooks pass
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]