Skip to content

fix: migrate ureq 2.x call sites to the resolved 3.x API - #36

Merged
hyperpolymath merged 2 commits into
mainfrom
fix/ureq-3x-migration
Jul 27, 2026
Merged

fix: migrate ureq 2.x call sites to the resolved 3.x API#36
hyperpolymath merged 2 commits into
mainfrom
fix/ureq-3x-migration

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Stacks on #35 — merge after it

This branches from fix/corrupt-cargo-lock (#35), not main. It must merge after #35, since it needs that branch's repaired Cargo.lock to build at all.

What's broken

src/main.rs used ureq 2.x-only APIs, but Cargo.toml already requires ureq = "3" and the lockfile resolves ureq 3.3.0. That mismatch means the crate has not compiled since the ureq bump landed:

error[E0599]: no method named `set` found for struct `RequestBuilder<B>` --> src/main.rs:66
error[E0599]: no variant, associated function, or constant named `Status` found for enum `ureq::Error` --> src/main.rs:70

Fix

Migrated the single HTTP call site to the ureq 3.3.0 API (verified against the actual crate source under ~/.cargo/registry, not from memory):

  • .set(k, v) -> .header(k, v)
  • .send_string(&s) -> .send(&s)
  • ureq::Error::Status(_, resp) is gone. ureq 3.x's default Error::StatusCode(u16) carries no response body, so the request now sets http_status_as_error(false) to keep 4xx/5xx responses arriving as Ok, preserving the original behaviour of still reading the JSON body of error responses instead of discarding it.
  • reading the body moved from Response::into_string() to Response<Body>::body_mut().read_to_string().

Went with migrating the code (not pinning Cargo.toml back to 2.x) because Cargo.toml already declares intent for ureq = "3" — the source was just never updated to match.

Why this matters for CI

Two separate Dependabot bumps landed back to back on this repo: one broke this source (ureq 2->3 API), the other corrupted Cargo.lock (crossterm listed twice, fixed in #35). Neither was caught because nothing in CI was actually running cargo build on this crate — both merged green. Worth adding a real build gate off the back of this.

Verification

hyperpolymathand others added 2 commits July 27, 2026 18:06
`cargo` refuses to parse the lockfile on `origin/main`:
error: failed to parse lock file at: Cargo.lock
Caused by: package `crossterm` is specified twice in the lockfile
It contained THREE `crossterm` entries — 0.28.1, 0.29.0 and 0.29.0. Two
identical versions is malformed; a package may appear more than once only at
distinct versions. Introduced by 56dc58d ("chore(deps): bump crossterm from
0.28.1 to 0.29.0", #4).
Regenerated with `cargo generate-lockfile`. The resolution is now 0.28.1
(direct, per `Cargo.toml`'s `crossterm = "0.28"`) plus 0.29.0 transitively —
two distinct versions, which is valid. `cargo metadata` now exits 0 where it
previously exited 101.
Found while adding container packaging: the build failed before compilation
even began, and reproduces identically with the host's own cargo 1.97.1
outside any container.
⚠ THIS DOES NOT MAKE THE CRATE BUILD. A separate, pre-existing breakage
remains — the source does not compile against the resolved `ureq`:
error[E0599]: no method named `set` found for struct `RequestBuilder<B>`
--> src/main.rs:66:10
error[E0599]: no variant named `Status` found for enum `ureq::Error`
--> src/main.rs:70:26
Both are ureq 2.x APIs removed in 3.x, so a dependency bump landed without the
corresponding source migration. That is left for a separate change rather than
bundled into a lockfile repair.
Taken together these mean coord-tui's CI has not been compiling this crate:
two dependency bumps merged, one breaking the source and one corrupting the
lockfile, with nothing red enough to stop them.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Cargo.toml already requests ureq = "3" and the lockfile resolves
ureq 3.3.0, so the crate hasn't compiled since that dependency was
bumped — the source still used 2.x-only methods:
- `.set(k, v)` -> `.header(k, v)`
- `.send_string(&s)` -> `.send(&s)`
- `ureq::Error::Status(_, resp)` no longer exists; 3.x's default
`Error::StatusCode(u16)` carries no response body at all. Disabled
`http_status_as_error` on the request so 4xx/5xx responses still
arrive as `Ok`, preserving the original fallback behaviour of
reading the JSON body of error responses instead of discarding it.
- reading the body moved from `Response::into_string()` to
`Response<Body>::body_mut().read_to_string()`.
Verified against the actual ureq-3.3.0 crate source under
~/.cargo/registry rather than from memory.
Two unrelated Dependabot bumps landed back to back on this repo: one
broke this source (ureq 2->3), the other corrupted Cargo.lock
(fixed separately in #35, which this branch is stacked on). Neither
was caught because CI was not actually compiling the crate — this is
the motivating case for adding a real `cargo build`/`cargo test`
gate rather than relying on green Dependabot PRs.
cargo build --release: exit 0
cargo test: exit 0 (0 tests present)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hyperpolymath
hyperpolymath marked this pull request as ready for review July 27, 2026 18:33
@hyperpolymath
hyperpolymath merged commit 12e126b into mainJul 27, 2026
12 checks passed
@hyperpolymath
hyperpolymath deleted the fix/ureq-3x-migration branch July 27, 2026 18:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@hyperpolymath