Skip to content

A timeout while reading an HTTP error body escapes save_file as something other than GitHubDocsError #14

Description

@dmccoystephenson

The claim

python/README.md (Errors section): "Everything that stopped an edit from landing raises GitHubDocsError".

What the code does

In GitHubDocsClient._request (python/src/github_docs/client.py), the except urllib.error.HTTPError as e: handler calls e.read() to read the error body. If that read times out, or the connection is reset during it, the resulting socket.timeout / OSError is raised inside the handler. Python does not route an exception raised within an except block to that block's sibling clauses, so the except OSError clause added for #11 does not catch it, and it escapes unconverted.

Suggested fix

Wrap e.read() in the HTTPError handler so that an OSError there falls back to an empty body (the status-only message "GitHub API returned HTTP " already exists for exactly that case). Add a TestErrorSurface case in which _http_error(...).read raises socket.timeout.

Found during the self-review of PR #13, and deliberately left out of that PR's scope.

This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions