Skip to content

fix(interpreter): build the HTTP client lazily so start-up needs no CA store - #657

Merged
logbie merged 2 commits into
mainfrom
warden/fix-nightly-eager-http-client
Jul 29, 2026
Merged

fix(interpreter): build the HTTP client lazily so start-up needs no CA store#657
logbie merged 2 commits into
mainfrom
warden/fix-nightly-eager-http-client

Conversation

@logbie

@logbie logbie commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

What was broken

The Nightly Build failed this morning — run 30426901237 (2026-07-29 06:02 UTC, main @ cded008).

The new Build WFL for Linux (static musl) job (added yesterday in #656) failed at "Prove portability on Debian 12 (wfl#616 regression gate)". Because the release job needs it, no nightly release was published today, even though the Windows build was green.

thread 'wfl-interpreter' panicked at reqwest-0.13.4/src/async_impl/client.rs:2507:38:
Client::new(): reqwest::Error { kind: Builder, source: General("No CA certificates were loaded from the system") }

Root cause

IoClient::new built the shared outbound HTTP client eagerly with reqwest::Client::new(), which unwraps the TLS builder instead of returning its error. reqwest 0.13 resolves roots through rustls-platform-verifier, and that fails when the system trust store is empty — so the interpreter aborted before the first statement of every WFL program on such a machine, whether or not the program touched the network.

debian:12-slim ships no ca-certificates, so the gate hit it immediately. Two things worth separating:

  • This is not a glibc problem. ./wfl --version and ./wfl-lsp --version both ran fine in the same container — those don't construct an Interpreter. The wfl#616 property the gate exists to protect is intact; the gate exposed a different, pre-existing defect on its first night.
  • The defect matters most exactly where a static musl binary is supposed to shine. Minimal/distroless container images are the primary audience for a no-glibc-floor binary, and they are precisely the images that ship no CA bundle.

Installing ca-certificates in the gate would have turned CI green while leaving that defect shipped, so this fixes the product instead.

The fix

One file, src/interpreter/mod.rs:

  • IoClient::http_client becomes a OnceCell<reqwest::Client>, built on first use by a new fallible IoClient::http_client() accessor (once_cell was already a direct dependency).
  • The four call sites (http_get, http_post, http_request, open_http_stream) become self.http_client()?.... All four already return Result<_, HttpClientError>, so a build failure now surfaces through the existing http_client_error path as a normal WFL runtime error.

Behaviour on a healthy system is unchanged: same builder, same settings, still one shared client (one connection pool per interpreter) — a test pins that. On a system with no CA store, start-up now succeeds and only a program that actually performs a request gets an error, instead of the process dying.

Two regression tests added alongside the existing IoClient tests:

  • io_client_new_does_not_build_the_http_client — the structural invariant. Does not compile against the eager field, which is the point.
  • http_client_is_built_once_and_reused — guards against a naive "build per request" fix that would silently drop connection pooling.

Verification

Local, Linux aarch64, rustc 1.97.1:

Check Result
cargo fmt --all -- --check clean
cargo clippy --all-targets --all-features -- -D warnings exit 0, zero warnings
cargo test --lib 672 passed, 0 failed, 6 ignored

And the failure itself was reproduced and confirmed fixed, using SSL_CERT_FILE/SSL_CERT_DIR pointed at a nonexistent path to simulate the empty trust store:

Binary Trust store wfl TestPrograms/basic_syntax_comprehensive.wfl
pre-fix (main) empty exit 101 — the identical client.rs:2507:38 panic
pre-fix (main) normal exit 0 (control)
this branch empty exit 0

Not run locally: cargo test --all (integration/database lanes need a release build and DB services, and the sandbox ran out of disk) and the Windows/MSI lanes. CI covers both here.

Note

Automated triage PR from the WFL repo warden — opened for a human to review and merge. I have not merged it. Once it lands, a workflow_dispatch of Nightly Build from main will confirm the gate passes and a release publishes.

Posted by the WFL repo warden (automated triage pass).


Open in Devin Review

View with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is enabled.

Summary by CodeRabbit

  • Bug Fixes
    • Improved startup reliability by delaying secure network client initialization until the first network request.
    • Prevented applications from failing during startup on systems with unavailable or empty certificate trust stores.
    • Reuses the initialized network client for subsequent requests.

…A store

`IoClient::new` called `reqwest::Client::new()`, which unwraps the TLS
builder rather than returning its error. That builder fails with
"No CA certificates were loaded from the system" on any machine whose
trust store is empty, so the interpreter aborted before the first
statement of *every* WFL program on such a machine - including programs
that never make a request.

The 2026-07-29 nightly caught this the first night the new static-musl
job ran its Debian 12 portability gate: `debian:12-slim` ships no
`ca-certificates`, so the shipped tarball panicked running
TestPrograms/basic_syntax_comprehensive.wfl. `wfl --version` and
`wfl-lsp --version` passed in the same container, so the wfl#616 glibc
property the gate exists for is fine - this is a separate defect the
gate happened to expose, and it matters most exactly where a static
musl binary is meant to shine: minimal container images.

Build the client on first use behind a `OnceCell` instead. Start-up no
longer touches the trust store, the client is still shared (one
connection pool per interpreter), and a genuinely unusable TLS stack now
surfaces as an ordinary WFL runtime error at the request that needs it
rather than killing the process.

Refs: run 30426901237, #616
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@logbie, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 894b6767-8df6-406f-b3a4-e64282eac1b2

📥 Commits

Reviewing files that changed from the base of the PR and between 4da9ded and 171eed1.

📒 Files selected for processing (1)
  • src/interpreter/mod.rs
📝 Walkthrough

Walkthrough

IoClient now lazily constructs and memoizes its shared reqwest::Client through OnceCell. HTTP request paths use the lazy accessor, and regression tests verify deferred construction and client reuse.

Changes

Lazy HTTP client initialization

Layer / File(s) Summary
Lazy client lifecycle
src/interpreter/mod.rs
IoClient stores its HTTP client in OnceCell, builds it on first access, and returns construction failures through HttpClientError.
Request integration and regression coverage
src/interpreter/mod.rs
GET, POST, and generic request paths use the lazy accessor; tests verify construction is deferred and the client is reused.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: lazy HTTP client initialization to avoid requiring a CA store at startup.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch warden/fix-nightly-eager-http-client

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/interpreter/mod.rs`:
- Around line 17673-17685: Update http_client_is_built_once_and_reused to handle
http_client() as a checked Result, skipping or returning cleanly when TLS
initialization fails while retaining pointer reuse assertions for successful
construction. Add coverage for a WFL request that triggers lazy client
initialization without try/when, ensuring the failure is surfaced as a catchable
RuntimeError rather than terminating interpreter startup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b77af559-ce5f-4443-8533-14c4ab94c057

📥 Commits

Reviewing files that changed from the base of the PR and between cded008 and 4da9ded.

📒 Files selected for processing (1)
  • src/interpreter/mod.rs

Comment thread src/interpreter/mod.rs
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
@logbie
logbie merged commit a5dd941 into main Jul 29, 2026
17 checks passed
@logbie
logbie deleted the warden/fix-nightly-eager-http-client branch July 29, 2026 09:52
Sign up for free to 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