Skip to content

proto: client Builder with both with_metadata_version and with_metadata_genesis produces an Accept value the RPC rejects for write methods #2623

Description

@Bruce039

Summary

miden_node_proto::clients::Builder builds the Accept header value in Interceptor::new. When both with_metadata_version(..) and with_metadata_genesis(..) are set, the (Some(version), Some(genesis)) arm emits

application/vnd.miden; version=X, genesis=0x...

The comma starts a second media range, so the server-side negotiation in crates/rpc/src/server/accept.rs sees two candidates: application/vnd.miden; version=X (no genesis, so it is skipped for methods with GenesisNegotiation::Mandatory) and genesis=0x..., which is not a media type and fails to parse. SubmitProvenTransaction / SubmitProvenTransactionBatch are rejected with

INVALID_ARGUMENT: accept header's media type could not be parsed
caused by: Invalid type name

The unit test in crates/proto/src/clients/mod.rs pins the wrong string, so CI does not catch it. Parameters of one media range must be separated with ; (the rust-sdk builds its own header that way, which is why it does not hit this).

Where

crates/proto/src/clients/mod.rs, impl Interceptor, fn new (the format! with "{}; {}={version}, {}={genesis}").

Reproduction

  • Unit test in crates/rpc/src/server/accept.rs: feed the value the builder produces for version = "0.2.3", genesis = 0x...deadbeef to negotiate(...) with mandatory genesis:
    accept value "application/vnd.miden; version=0.2.3, genesis=0x0000…deadbeef" was rejected: accept header's media type could not be parsed
    
  • End-to-end test in crates/rpc/src/tests.rs: build a client with Builder::new(..).with_metadata_version(..).with_metadata_genesis(..) against the in-process RPC server and call submit_proven_transaction:
    expected the request to reach the handler, got: code: 'Client specified an invalid argument', message: "accept header's media type could not be parsed\ncaused by: Invalid type name"
    

Impact

Any client built with the published Builder and both metadata options cannot submit anything; the error points at the header syntax rather than at the builder.

Proposed fix

Use ; as the separator in the (Some, Some) arm and fix the unit test that pins the current value. It is worth checking the builder output against the real negotiator in the rpc crate's tests (a small Interceptor::new_for_tests helper is enough) so the two sides cannot drift again.

I have the change and the two tests ready (miden-node-rpc + miden-node-proto: 173 tests pass, clippy clean) and can open a PR if this is assigned to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions