Send x-build-version header for every request#229
Conversation
We are sending x-build-version on every request and fail if the sdk version is too old resolves #195
|
Warning Review limit reached
Your plan includes 1 review of capacity. Refill in 31 minutes and 4 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ 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 implementation
Reviewed all 6 changed files + full file context + cross-repo impact + git history + issue #195 requirements.
Summary
Adds x-build-version / X-Build-Version header to every gRPC and REST request, using CARGO_PKG_VERSION (currently 0.9.0). Adds is_version_mismatch() helper to both error types for detecting BUILD_VERSION_TOO_OLD server rejections.
What's correct
- gRPC (
ark-grpc/src/client.rs):VersionInterceptorapplied to bothArkServiceClientandIndexerServiceClientviawith_interceptor. Uses a sharedChannel(cloned cheaply — it's Arc-wrapped). Clean. - REST (
ark-rest/src/client.rs):reqwest::Client::builder().default_headers()— propagates to all requests including SSE event streams (lines 305, 530 useself.configuration.client). Clean. - Version source:
env!("CARGO_PKG_VERSION")→&'static strat compile time.from_static()is valid. Correct. - Connection optimization: gRPC
connect()now creates one channel shared by both service clients instead of two separate connections. Strictly better. - Custom
Debugimpl: Required becauseInterceptedServicedoesn't deriveDebug. The impl is reasonable. - Test coverage:
is_version_mismatchtests cover: matching status, wrong message, wrong code, non-tonic source, no source. Good coverage.
Breaking change — acceptable
ark_rest::Client::new() signature changed: -> Self → -> Result<Self, Error>. All in-tree callers updated (wasm tests, e2e tests). No external consumers found across the full monorepo (/root/arkana/repos/). Downstream crates depending on ark-rest will get a compile error — this is a semver-minor break at worst, and version is pre-1.0 (0.9.0), so acceptable.
Minor observations (non-blocking)
-
ark-rest/src/error.rs:44-47—is_version_mismatchis less precise than the gRPC version. The REST impl doessource.to_string().contains("BUILD_VERSION_TOO_OLD")without checking HTTP status code. The gRPC version checks bothFailedPreconditionAND message content. In practice unlikely to cause false positives, but worth noting the asymmetry. -
No integration test that the header is actually sent. Issue #195 lists "Add tests verifying the header is sent" as a requirement. The current tests only cover error detection. A test that inspects outgoing headers (e.g., against a mock server) would close that gap. Not blocking for merge.
-
reqwest::Client::builder().build()is infallible in practice (only fails with conflicting TLS config). TheResultreturn fromClient::new()is technically correct but will never fail with the current code. Fine for future-proofing.
Not protocol-critical — no VTXOs, signing, forfeit paths, or round lifecycle touched. Ship it.
Resolves #195.
I merged #210 against a different branch by mistake.