Repository navigation
fix(ra-rpc): bound the error text a failed call returns, and return it in the caller's representation - #1234
Merged
Merged
Conversation
A deserializer names the value it rejected, so the message is as long as
the request field that produced it. Both the reply body and the log line
carry it verbatim:
$ curl --unix-socket /var/run/dstack.sock -X POST \
-H 'Content-Type: application/json' --data-binary @9mib.json \
http://localhost/prpc/Tappd.DeriveKey
http=400 size=9437272
$ awk '{ print length($0) }' simulator.log | sort -rn | head -1
9437466
One malformed request is a 9 MiB reply and a 9 MiB log line, at the
default 10 MiB request limit. That is a response amplifier on every
network-facing listener, and a way to fill a service's disk from a
listener that needs no credential -- the guest agent's socket is
bind-mounted into application containers by design.
Bound the text at 2 KiB, dropping the middle rather than the tail: a
deserializer puts the failure kind in front of the value and the input
position behind it, so both ends carry information the caller needs. No
real dstack error is anywhere near the bound, so nothing legitimate is
truncated.
`handle` encoded a pre-dispatch failure using `request.json`, which is
only `true` for a GET or an explicit `?json`. `handle_prpc_impl` decided
the same question with the content type as well. So a plain
POST /prpc/Tappd.DeriveKey
Content-Type: application/json
whose failure was raised before the dispatcher ran came back as
HTTP/1.1 413 Payload Too Large
content-type: application/octet-stream
\n&failed to read data: payload too large
-- a protobuf `ProtoError` that no JSON client can read, under a content
type it did not ask for. Everything raised on that path is affected:
`payload too large`, a certificate that will not parse, and `invalid
quote`, which is the one an attested caller most needs to see.
Resolve the representation once, before anything moves out of the
request, and use it on both paths.
kvinwang
added a commit
that referenced
this pull request
Sep 20, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
Collaborator
Author
tdxlab hardware run: before and afterThe new Against the suite branch alone (no product fix — run
The 225 is one abort plus the cascade: every later call in that sweep failed to connect, because the process was gone. With #1232 and #1234 merged in (run |
This was referenced Sep 20, 2026
kvinwang
added a commit
that referenced
this pull request
Sep 24, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Sep 24, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Sep 25, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Sep 25, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 8, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Nov 8, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 8, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Nov 8, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 10, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Nov 10, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 11, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Nov 11, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 11, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Nov 11, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
kvinwang
added a commit
that referenced
this pull request
Nov 16, 2026
Every RPC case in this suite names api-inventory.json as mandatory test data and states that the method is exercised with its request fields "absent/default, valid, boundary-invalid and combined with an unknown field" in both representations. The harnesses behind those cases send one valid request and one wrong-typed value for the *first* request field. So the input classes where a service actually breaks -- an out-of-range integer, an oversized string, a wrong protobuf wire type, a truncated body -- are untested for all 110 indexed methods. Add a harness that implements the stated matrix once, driven by the same inventory, and nine cases that apply it to the guest agent's four services, the KMS's two, and the gateway's three. It asserts the invariants that hold for every method whatever it means: a malformed request is never a 5xx or a dropped connection, a rejection is structured and bounded and carries the caller's own representation, no call outlives its deadline, and the listener still answers afterwards. That last one is a real assertion here: the workspace builds release binaries with `panic = "abort"`, so a reachable panic is a process abort. api-contract-matrix-policy.json says how far each method may be driven. `full` is for a method whose effect stays inside the lease; `rejection-only` sends only what a service must refuse before it dispatches, so nothing can mutate; `skip` is for a method whose valid invocation ends the process or consumes an external resource, and the file records the reason for each. Every method in the inventory must carry a policy -- one added without one fails the case rather than being silently skipped. Two product defects found while building this are fixed separately: a `not_after` of u64::MAX aborted the guest agent (#1232), and a rejection echoed the whole rejected value back to the caller and into the log under a content type the caller did not ask for (#1234).
kvinwang
added a commit
that referenced
this pull request
Nov 16, 2026
…ct matrix PR #1234 caps pRPC error text at 2 KiB and answers a JSON request refused before dispatch in JSON; L4 now bounds the decoded error text and L6 covers the pre-dispatch refusal. PR #1401 keeps caller text from starting a log line; the gateway contract cases send a method segment carrying a percent-encoded line break and require no log line to begin with the marker (L7). Signed-off-by: Kevin Wang <wy721@qq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two defects on the shared pRPC error path (every service: guest agent, gateway, KMS, VMM).
rpc error:log line (reachable unauthenticated via/var/run/dstack.sock). Error text is now capped at 2 KiB, dropping the middle so the error kind and input position both survive.PrpcHandler::handleonly checked?json/GET, so a JSONPOSTrejected before dispatch (payload too large, bad cert, invalid quote) got a protobuf body withapplication/octet-stream. Both paths now use onewants_json().Verification
a_json_request_is_refused_in_json_before_the_dispatcher_runsanda_rejection_does_not_echo_the_whole_offending_valuefail onnext(content-type application/octet-stream;a rejection echoed 1048664 bytes) and pass here; a unit test covers multi-byte char boundaries.cargo test -p ra-rpc,cargo clippy -p ra-rpc --all-features -- -D warnings,cargo fmt --check: clean.