fix(grpc): set tls_config on manual endpoint connect#233
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesgRPC Client TLS Configuration Restoration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
✅ Approved
Clean, well-scoped fix for the TLS regression introduced in #229. Reviewed the full diff and surrounding client.rs context.
What it does
PR #229 switched from ArkServiceClient::connect(url) (which auto-configured TLS via feature flags) to manual Endpoint::from_shared(url).connect(), which does not auto-apply ClientTlsConfig. This PR correctly bridges that gap by explicitly building and applying a ClientTlsConfig when TLS features are enabled.
Verified
- Feature gating is correct. The TLS block is behind
#[cfg(any(feature = "tls-webpki-roots", feature = "tls-native-roots"))], so non-TLS builds are unaffected. - Error handling is correct.
tls_config()returnsResultand is properly propagated viamap_err(Error::connect)?. - No public API change.
connect(&mut self) -> Result<(), Error>signature is unchanged — zero cross-repo impact. Downstream consumers (ark-client,ark-rs,e2e-tests,ark-client-sample) are unaffected. - Feature forwarding is consistent.
ark-client/Cargo.tomlandark-rs/Cargo.tomlboth forwardtls-webpki-roots/tls-native-rootstoark-grpc, so the right#[cfg]paths activate. - Default features (
tls-webpki-roots) mean the common case —cargo buildwith defaults — gets webpki roots applied, which is the correct fix for the reported issue. - Not protocol-critical. This is transport-layer plumbing; no VTXO, signing, forfeit, or round-lifecycle code is touched.
Nit (non-blocking)
ark-grpc/src/client.rs — dual-feature edge case. If a consumer enables both tls-webpki-roots and tls-native-roots, both with_webpki_roots() and with_native_roots() are called sequentially. In tonic 0.14, the second call likely overrides the first (native roots win). This is harmless in practice — Cargo feature flags are additive and enabling both is unusual — but a #[cfg(all(...))] compile error or a doc comment noting the precedence would prevent future confusion. Not a blocker.
LGTM. Ship it.
There was a problem hiding this comment.
✅ Approved
Clean, well-scoped fix for the TLS regression introduced in #229. Reviewed the full diff and surrounding client.rs context.
What it does
PR #229 switched from ArkServiceClient::connect(url) (which auto-configured TLS via feature flags) to manual Endpoint::from_shared(url).connect(), which does not auto-apply ClientTlsConfig. This PR correctly bridges that gap by explicitly building and applying a ClientTlsConfig when TLS features are enabled.
Verified
- Feature gating is correct. The TLS block is behind
#[cfg(any(feature = "tls-webpki-roots", feature = "tls-native-roots"))], so non-TLS builds are unaffected. - Error handling is correct.
tls_config()returnsResultand is properly propagated viamap_err(Error::connect)?. - No public API change.
connect(&mut self) -> Result<(), Error>signature is unchanged — zero cross-repo impact. Downstream consumers (ark-client,ark-rs,e2e-tests,ark-client-sample) are unaffected. - Feature forwarding is consistent.
ark-client/Cargo.tomlandark-rs/Cargo.tomlboth forwardtls-webpki-roots/tls-native-rootstoark-grpc, so the right#[cfg]paths activate. - Default features (
tls-webpki-roots) mean the common case —cargo buildwith defaults — gets webpki roots applied, which is the correct fix for the reported issue. - Not protocol-critical. This is transport-layer plumbing; no VTXO, signing, forfeit, or round-lifecycle code is touched.
Nit (non-blocking)
ark-grpc/src/client.rs — dual-feature edge case. If a consumer enables both tls-webpki-roots and tls-native-roots, both with_webpki_roots() and with_native_roots() are called sequentially. In tonic 0.14, the second call likely overrides the first (native roots win). This is harmless in practice — Cargo feature flags are additive and enabling both is unusual — but a #[cfg(all(...))] compile error or a doc comment noting the precedence would prevent future confusion. Not a blocker.
LGTM. Ship it.
There was a problem hiding this comment.
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 `@ark-grpc/src/client.rs`:
- Around line 123-131: The TLS config is being applied unconditionally which can
wrap plaintext HTTP endpoints and break runtime behavior; before calling
endpoint.tls_config(tls) (where tls is a tonic::transport::ClientTlsConfig
created in the cfg block), check the endpoint URI/scheme and only invoke
Endpoint::tls_config when the scheme is https (or otherwise indicates TLS).
Locate the code that builds the endpoint (the variable endpoint) and the
ClientTlsConfig construction and add a guard that inspects endpoint.uri() or
equivalent scheme parsing so tls_config is only called for https schemes,
returning or leaving endpoint unchanged for http.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cc4c5014-527d-4619-8be5-9260f582474f
📒 Files selected for processing (1)
ark-grpc/src/client.rs
luckysori
left a comment
There was a problem hiding this comment.
Thank you for the fix!
This is my bad. I specifically ran into this bug locally testing against mutinynet and fixed it, but forgot to merge the fix.
I will merge and deploy 0.9.3 now.
#229 switched
Client::connectfrom the generatedClient::connect(url)static to building the channel manually viaEndpoint::from_shared(url).connect(), but the manual path does not apply TLS configuration. In tonic 0.14 thetls-webpki-roots/tls-native-rootsfeature flags pull in rustls without auto-configuring aClientTlsConfig, so HTTPS Ark servers became unreachable in v0.9.1 with a generic transport error.Apply
ClientTlsConfigwith webpki or native roots based on the enabled feature flag, gated so non-TLS builds remain unaffected.Resolves #232.
Summary by CodeRabbit