roc-lang / roc-lang/basic-cli

Make Http.TransportErr match host error behavior

Open
#438 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
121
Forks
45
Avg merge
18h 43m
Merged PRs (30d)
10

Description

Context

InternalHttp.TransportErr declares:

[Timeout, NetworkError, BadBody, Other(List(U8))]

in platform/InternalHttp.roc:12.

The Rust host constructs Timeout, BadBody, and Other, but never constructs NetworkError. Every error returned by client.request(request).await is converted to Other(err.to_string().as_bytes()) at src/http.rs:167-170.

The connection-refused integration scenario currently demonstrates this behavior: it produces HttpErr(Other(... "client error (Connect)" ...)).

This is related to #142, which was closed because error details are now retained in Other. The remaining problem is that the public union still advertises an unreachable NetworkError variant.

Suggested direction

Choose and document one consistent contract:

  1. classify DNS/connect/TLS/socket failures as NetworkError(details), potentially changing its payload; or
  2. remove NetworkError and define when Other is used.

Prefer stable structured categories over matching Hyper's display strings. Preserve useful diagnostic details without making callers parse text to identify ordinary network failures.

Acceptance criteria

  • Every public TransportErr variant has a documented, reachable meaning, or unreachable variants are removed.
  • Connection refused, DNS failure, TLS failure, timeout, invalid response body, and request-construction failure are mapped intentionally.
  • Tests assert error variants, not only that an HTTP request failed.
  • Documentation and examples reflect the final error shape.
  • Any API change is included in the release bump check.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the public TransportErr declaration in platform/InternalHttp.roc:12 and the request error conversion in src/http.rs:167-170, then inspect the connection-refused integration scenario. Define and document the final mapping for each listed failure, update tests to assert variants, align documentation and examples, and include any API change in the release bump check.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, cli, networking, release, testing
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.