Skip to content

blasthttp.mock raises RuntimeError where the real client raises TransportError #140

Open

Description

@liquidsec

On the 1.0 branch (#128, as of 3e1629e), the real client raises TransportError for every failed request. The mock raises a plain RuntimeError instead:

  • an unmocked URL: "No mock response registered for {method} {url}" (src/mock.rs:442)
  • too many redirects during mock dispatch (src/mock.rs:804)

TransportError subclasses RuntimeError, so code written as except RuntimeError behaves the same against both. Code written against the new API, except TransportError and branching on e.kind, does not: under the mock, an unmocked URL escapes the handler and crashes the caller, where against the real client it would have been caught.

That forces consumers to keep catching RuntimeError and to guard every e.kind access with getattr, which defeats the point of the new exception. In BBOT's test suite, modules routinely hit URLs that a test doesn't mock, so this blocks BBOT from switching its handlers to TransportError.

Suggested fix: raise TransportError from the mock with the attributes filled in, for example kind="connection" for an unmocked URL and kind="too_many_redirects" for the redirect limit, with conclusion="unreachable". Ideally the mock could also be told to fail a URL with a chosen kind (timeout, tls, etc.), so consumers can test their handling of each one.

Activity

  1. added a commit that references this issue on Oct 26, 2026
    b9e1434
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