Skip to content

fix(responses): a canned reply outside 2xx reads error on Tendermint RPC, and a gRPC provider refuses a canned body - #170

Merged
VicSheCodes merged 2 commits into
mainfrom
canned-reply-review-fixes
Oct 26, 2026
Merged

VicSheCodes merged 2 commits into
mainfrom
canned-reply-review-fixes

Conversation

@VicSheCodes

@VicSheCodes VicSheCodes commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Why

A review of PR #169 (a canned reply can carry an error status, and the history records it as error) found gaps after it merged, and a review of this branch found three more:

  • On Tendermint RPC a canned reply with an error status was recorded as success. The chain wraps a canned body as the result of the reply, and the Tendermint listener had no label rule of its own, so the label read only the body.
  • The gRPC listener never reads a canned body. A body under a method name on a gRPC provider was stored and changed no reply. feat(responses): a canned reply can carry an error status, and the history records it as error #169 turned the refusal of an error status there into silent acceptance.
  • Tendermint RPC reads http_status as the status of a canned reply, as it reads status, but only status was validated. A text "503" fell back to HTTP 200, and a 302 was sent.
  • The tests of the label used bodies that agreed with their status. A rule that also read the body, or that called only 200 a success, passed them.

What changed

  • provider_simulator/listeners/tendermint.py: every reply outside 2xx reads error in the history, as on REST and GraphQL: a canned reply, and a reply whose status a provider-wide http_status sets. Inside 2xx the label is unchanged.
  • provider_simulator/control_api.py:
    • status and http_status beside a canned body both must be an int from 200 to 299 or from 400 to 599. The message for status keeps the wording of feat(responses): a canned reply can carry an error status, and the history records it as error #169.
    • _a_canned_body_no_endpoint_can_serve refuses a body under a method name on a provider that has a gRPC endpoint and no JSON-RPC, GraphQL or Tendermint RPC endpoint, with HTTP 400 that names the entry, the endpoints of the provider, and the keys a gRPC endpoint reads (result, error, error_stub). A REST [verb, template] entry on a provider with a REST endpoint is accepted. Like the two corruption rules beside it, it reads the endpoints of the provider and no filter.
  • Tests:
    • tests/test_listener_tendermint.py: a canned 503 set with status or with http_status reads error, a canned 299 reads success, and a provider-wide http_status of 302 or 503 reads error while 200 reads success.
    • tests/test_control_api.py: a canned body on lava-sim-grpc:1, with status 200 or 503, is refused, and so is a body under a method name on a provider with a gRPC and a REST endpoint. A canned http_status of 302, 100, "503" or true is refused. The controls: a result on the gRPC provider, a canned body on JSON-RPC and on Tendermint RPC, a canned http_status of 503, and a REST pair on the provider with a REST endpoint are accepted.
    • tests/test_simulator_per_method_overrides.py: a canned 503 whose body holds no error reads error, and a canned 299 whose body holds an error reads success.
  • Text that feat(responses): a canned reply can carry an error status, and the history records it as error #169 made untrue: two docstrings and one failure message in tests/test_simulator_per_method_overrides.py, the heading in provider_simulator/listeners/jsonrpc.py, the comment above the status check in control_api.py, the Tendermint module docstring, and docs/using_the_simulator.md: the canned reply on each interface, the rule for both status keys, the label of every Tendermint reply, the gRPC refusal, and the canned body in the GraphQL table.

How to verify

pytest tests/test_listener_tendermint.py tests/test_control_api.py tests/test_simulator_per_method_overrides.py -v

Results

Not in this pull request

  • These settings are accepted and change nothing, for a 2xx canned reply too, before and after feat(responses): a canned reply can carry an error status, and the history records it as error #169: a valid http_status in place of status on JSON-RPC or GraphQL, a status with no body, and a window such as fail_first_n beside a canned reply, which the canned branch never reads.
  • On JSON-RPC a reply that the chain builds is labelled by its body, so a provider-wide http_status outside 2xx with a result body reads success there, and error on Tendermint RPC, REST and GraphQL.
  • A WebSocket frame has no HTTP status. A canned reply with an error status sends its body in the frame, and the row reads error.

…RPC, and a gRPC provider refuses a canned body

A review of the canned reply with an error status found three gaps.

Tendermint RPC serves a canned body as the result of the reply, with its
status or http_status. Its listener had no label rule of its own, so a
canned 503 was recorded as success. It now records a reply outside 2xx as
error, as REST and GraphQL do.

The gRPC listener never reads a canned body. A body on a provider with
only gRPC endpoints was stored and changed no reply; with the error
status now accepted, that reached more scenarios. The control API now
refuses it, as it refuses the other settings a provider cannot apply,
and names the keys a gRPC provider reads.

The tests of the label used bodies that agreed with their status, so a
rule that also read the body, or called only 200 a success, passed them.
A canned 503 with no error in its body, and a canned 299 with an error,
now pin the rule. Each of three broken label rules fails one of them.

Text that the canned error status made untrue is corrected: the test
docstrings and one failure message, the heading in jsonrpc.py, the
control API comment, and the user guide with its GraphQL table.
@VicSheCodes
VicSheCodes requested a review from idanhen1 as a code owner October 26, 2026 20:13
@VicSheCodes VicSheCodes added the no-ticket PR intentionally closes no Jira ticket label Oct 26, 2026
@VicSheCodes VicSheCodes self-assigned this Oct 26, 2026
… a body no endpoint of a gRPC provider serves

A review of this branch found three gaps.

Tendermint RPC reads http_status as the status of a canned reply, as it
reads status, but only status was validated. A text "503" fell back to
HTTP 200 and changed no reply, and a 302 was sent. Both keys now get the
same rule: an int from 200 to 299 or from 400 to 599.

The gRPC rule refused a body only when every endpoint was gRPC. A provider
with a REST endpoint beside its gRPC one accepted a body under a method
name, and no endpoint served it: REST reads a [verb, template] pair. The
rule now refuses such a body on a provider that has a gRPC endpoint and
no JSON-RPC, GraphQL or Tendermint RPC endpoint.

The Tendermint label covers every reply outside 2xx, also one whose
status a provider-wide http_status sets. A test now pins that, a 302
included: a rule that called only 400 and up an error fails it.

The user guide states the rule for both keys, the wider Tendermint
label, the narrower gRPC refusal, and that a GraphQL canned reply needs
no status.
@VicSheCodes
VicSheCodes merged commit 9a1f1be into main Oct 26, 2026
9 checks passed
@VicSheCodes
VicSheCodes deleted the canned-reply-review-fixes branch October 26, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-ticket PR intentionally closes no Jira ticket

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant