fix: exact version match in accept header validation#1753
fix: exact version match in accept header validation#1753mmagician wants to merge 1 commit intorelease/v0.14.0-alphafrom
Conversation
The AcceptHeaderLayer was constructing a semver comparator with patch: None and pre: Prerelease::default() (empty), which created a requirement like =0.14. This had two problems: 1. It allowed any patch version (e.g. a client at 0.14.1 could connect to a 0.14.0 node) 2. It rejected ALL pre-release versions, since semver matching rules exclude pre-releases when the comparator has no pre-release component This meant that during the alpha release cycle, no client could ever pass version negotiation - a client at 0.14.0-alpha.1 was rejected by a node at 0.14.0-alpha.3, and even a client at 0.14.0-alpha.3 was rejected by its own node. The fix includes the full version (patch + pre-release) in the comparator, so the node requires an exact version match. For example, a node at 0.14.0-alpha.3 now accepts only clients at 0.14.0-alpha.3. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
afb79eb to
11a09a6
Compare
igamigo
left a comment
There was a problem hiding this comment.
LGTM! I guess another potential fix could've been to strip the alpha suffix from the client's side, but this sounds like it's more correct even if it incurs another release
|
Makes sense I'm just not certain we want this behaviour:
Might be more helpful to require exact match on alpha/beta and ignore the number? |
I think this may be preferable as well. Basically, we'd have |
|
I think this indicates that its time to version the gRPC schema separately since its largely more stable than the number of versions we'll be releasing elsewhere. The main thing preventing this is the protocol types which we raw encode. Since we effectively inherit its stability as well. But we could also pin the version used in the grpc crate(s) to get some stability guarantees. Given that ^^ should be our target (~soonish), I think we can just do something lenient for the |
We discussed both options in the sync meeting and the current approach (of exact match on both In any case, the other approach is relatively simple as well, I opened another PR targeting the same branch to compare: #1755 |
|
We can close this after #1755 got merged, right? |
Summary
The
AcceptHeaderLayer::newconstructs a semverComparatorwithpatch: Noneandpre: Prerelease::default()(empty), effectively creating a version requirement like=0.14. While thepatch: Nonecorrectly allows any patch version through (so0.14.0and0.14.1are both accepted), the empty pre-release causes semver'sVersionReq::matchesto reject all pre-release versions. Per semver matching rules, a comparator without a pre-release component never matches versions that have one.This means during the alpha release cycle, no client can pass version negotiation - a client at
0.14.0-alpha.3is rejected even by its own node at0.14.0-alpha.3.Fix
The
VersionReqalone can't express "match major.minor with any patch, but require exact pre-release" because of how semver treats pre-release comparisons. Instead, we:VersionReqas-is for major.minor matching (withpatch: None,pre: empty)expected_prenegotiate, strip the pre-release from the client version before checkingVersionReq, then check the pre-release tag separately for an exact matchThis gives us the desired compatibility rules:
0.14.0and0.14.1are both accepted by a0.14.0nodealpha.3only matchesalpha.3, notalpha.1orbeta.30.14.0client is rejected by a0.14.0-alpha.3node and vice versaTest changes
version_prerelease_rejected_by_stablecase (a stable server rejects pre-release clients)prereleasetest module that creates a server at0.14.0-alpha.3and verifies:0.14.1-alpha.3)alpha.1) is rejectedbeta.3) is rejected0.14.0) is rejectedContext
Discovered while running integration tests for the miden-client
release/v0.14.0-alphabranch. The client (at0.14.0-alpha.1) was rejected by the test node (built frommiden-node-rpcat0.14.0-alpha.3) with:See: https://github.com/0xMiden/miden-client/actions/runs/22726117886/job/65902524781?pr=1862