feat: Send x-build-version header for every request#210
feat: Send x-build-version header for every request#210bonomat wants to merge 1 commit intochore/bump-to-0.9.2from
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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.
Review: feat: Send x-build-version header for every request
Reviewed full diff + full file context + server-side interceptor in arkd. Not protocol-critical (no VTXO/signing/forfeit/exit paths touched). Findings below.
🔴 Dead code: from_tonic_status never called, Kind::VersionMismatch never constructed
ark-grpc/src/error.rs — from_tonic_status() is defined but zero call sites exist. Every gRPC call in ark-grpc/src/client.rs still uses .map_err(Error::request) (18 call sites). This means Kind::VersionMismatch is never constructed — it's dead code.
The is_version_mismatch() method does work regardless (it downcasts the source to tonic::Status and checks there), so the detection itself is fine. But the Kind::VersionMismatch variant and from_tonic_status serve no purpose as written. Either:
- Wire
from_tonic_statusinto the call sites (replacingError::requestfor tonic status errors), or - Remove
Kind::VersionMismatchandfrom_tonic_statusentirely —is_version_mismatch()already works without them.
Same issue in ark-rest/src/error.rs: Kind::VersionMismatch added but never constructed.
🟡 ark-rest/src/client.rs:63 — expect() panics in a library
.expect("failed to build HTTP client");Panicking in library code is poor practice. Yes, building a reqwest client with just default headers is unlikely to fail, but this is a public constructor. Consider returning Result<Self, Error> or using unwrap_or_default() for the client builder and documenting the invariant.
🟡 REST is_version_mismatch is fragile compared to gRPC version
ark-rest/src/error.rs — The REST version does:
source.to_string().contains("BUILD_VERSION_TOO_OLD")This relies on the server's error message string surviving through reqwest's error chain as a .to_string(). Unlike the gRPC version (which properly downcasts to tonic::Status and checks code + message), this is fragile. If reqwest wraps the response body differently, or the server changes its error format, this silently breaks. Consider checking the HTTP status code (412 or 400?) alongside the body content.
🟡 No tests
No tests for:
- Version header actually being sent (could be an integration test with a mock server)
is_version_mismatch()returningtruewhen given aBUILD_VERSION_TOO_OLDstatusis_version_mismatch()returningfalsefor other errors
The server-side interceptor is well-tested in arkd, but the client-side detection logic is untested.
✅ What looks good
- gRPC interceptor pattern is clean —
VersionInterceptorwithtonic::service::Interceptoris the right approach. - Single channel, two clients — the refactor from two separate
connect()calls to one shared channel is an improvement (fewer TCP connections). env!("CARGO_PKG_VERSION")— compile-time, zero-cost. Correct.from_static— avoids per-request allocation. Good.- Manual
Debugimpl — necessary sinceInterceptedServicedoesn't deriveDebug. Implementation is fine. - Server behavior is safe — per arkd docs, missing header = request allowed, malformed version = request allowed. No risk of breaking existing clients.
- Cross-repo: ts-sdk, go-sdk, dotnet-sdk don't send this header yet — no breakage since server allows missing headers.
Summary
The core feature (sending the version header) is correct and well-implemented. The dead code (from_tonic_status, Kind::VersionMismatch) and the expect() panic should be cleaned up before merge. The lack of tests for is_version_mismatch() is a moderate concern — it's a public API method that callers will rely on.
There was a problem hiding this comment.
Review: feat: Send x-build-version header for every request
Reviewed full diff + full file context + server-side interceptor in arkd. Not protocol-critical (no VTXO/signing/forfeit/exit paths touched). Findings below.
🔴 Dead code: from_tonic_status never called, Kind::VersionMismatch never constructed
ark-grpc/src/error.rs — from_tonic_status() is defined but zero call sites exist. Every gRPC call in ark-grpc/src/client.rs still uses .map_err(Error::request) (18 call sites). This means Kind::VersionMismatch is never constructed — it's dead code.
The is_version_mismatch() method does work regardless (it downcasts the source to tonic::Status and checks there), so the detection itself is fine. But the Kind::VersionMismatch variant and from_tonic_status serve no purpose as written. Either:
- Wire
from_tonic_statusinto the call sites (replacingError::requestfor tonic status errors), or - Remove
Kind::VersionMismatchandfrom_tonic_statusentirely —is_version_mismatch()already works without them.
Same issue in ark-rest/src/error.rs: Kind::VersionMismatch added but never constructed.
🟡 ark-rest/src/client.rs:63 — expect() panics in a library
.expect("failed to build HTTP client");Panicking in library code is poor practice. Yes, building a reqwest client with just default headers is unlikely to fail, but this is a public constructor. Consider returning Result<Self, Error> or using unwrap_or_default() for the client builder and documenting the invariant.
🟡 REST is_version_mismatch is fragile compared to gRPC version
ark-rest/src/error.rs — The REST version does:
source.to_string().contains("BUILD_VERSION_TOO_OLD")This relies on the server's error message string surviving through reqwest's error chain as a .to_string(). Unlike the gRPC version (which properly downcasts to tonic::Status and checks code + message), this is fragile. If reqwest wraps the response body differently, or the server changes its error format, this silently breaks. Consider checking the HTTP status code (412 or 400?) alongside the body content.
🟡 No tests
No tests for:
- Version header actually being sent (could be an integration test with a mock server)
is_version_mismatch()returningtruewhen given aBUILD_VERSION_TOO_OLDstatusis_version_mismatch()returningfalsefor other errors
The server-side interceptor is well-tested in arkd, but the client-side detection logic is untested.
✅ What looks good
- gRPC interceptor pattern is clean —
VersionInterceptorwithtonic::service::Interceptoris the right approach. - Single channel, two clients — the refactor from two separate
connect()calls to one shared channel is an improvement (fewer TCP connections). env!("CARGO_PKG_VERSION")— compile-time, zero-cost. Correct.from_static— avoids per-request allocation. Good.- Manual
Debugimpl — necessary sinceInterceptedServicedoesn't deriveDebug. Implementation is fine. - Server behavior is safe — per arkd docs, missing header = request allowed, malformed version = request allowed. No risk of breaking existing clients.
- Cross-repo: ts-sdk, go-sdk, dotnet-sdk don't send this header yet — no breakage since server allows missing headers.
Summary
The core feature (sending the version header) is correct and well-implemented. The dead code (from_tonic_status, Kind::VersionMismatch) and the expect() panic should be cleaned up before merge. The lack of tests for is_version_mismatch() is a moderate concern — it's a public API method that callers will rely on.
We are sending x-build-version on every request and fail if the sdk version is too old resolves #195
e0ffc86 to
bccdd01
Compare
|
Arkana follow-up — No new commits since my last review ( |
We are sending x-build-version on every request and fail if the sdk version is too old
resolves #195