Skip to content

Commit eaeaa31

Browse files
committed
Cover both directions of the failing-codec test
The raising-codec stub's unseal was never executed, failing the coverage gate; drive it through a retry and assert the frozen rejection. Keep trailing assertions inside the client context so branch arcs resolve on every interpreter in the matrix.
1 parent 471cdd9 commit eaeaa31

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

tests/server/test_request_state_boundary.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,9 +1082,13 @@ async def test_a_codec_that_raises_during_seal_yields_a_sanitized_internal_error
10821082
async with Client(mcp) as client:
10831083
with pytest.raises(MCPError) as exc:
10841084
await client.session.call_tool("deploy", {"env": "prod"}, allow_input_required=True)
1085-
1086-
assert exc.value.error.code == INTERNAL_ERROR
1087-
assert exc.value.error.message == "Internal error"
1085+
# The unseal direction of the same broken codec still maps to the frozen rejection.
1086+
with pytest.raises(MCPError) as inbound:
1087+
await _retry(client, "deploy", {"env": "prod"}, "token-this-codec-never-minted")
1088+
assert exc.value.error.code == INTERNAL_ERROR
1089+
assert exc.value.error.message == "Internal error"
1090+
_assert_frozen_rejection(inbound)
1091+
_assert_frozen_rejection(inbound)
10881092

10891093

10901094
async def test_a_non_string_principal_fails_closed_when_sealing() -> None:
@@ -1099,9 +1103,8 @@ def numeric_user_id(ctx: ServerRequestContext[Any, Any]) -> str:
10991103
async with Client(mcp) as client:
11001104
with pytest.raises(MCPError) as exc:
11011105
await client.session.call_tool("deploy", {"env": "prod"}, allow_input_required=True)
1102-
1103-
assert exc.value.error.code == INTERNAL_ERROR
1104-
assert exc.value.error.message == "Internal error"
1106+
assert exc.value.error.code == INTERNAL_ERROR
1107+
assert exc.value.error.message == "Internal error"
11051108

11061109

11071110
async def test_a_non_string_principal_fails_closed_when_verifying() -> None:
@@ -1115,9 +1118,8 @@ async def test_a_non_string_principal_fails_closed_when_verifying() -> None:
11151118
principal[0] = 12345
11161119
with pytest.raises(MCPError) as exc:
11171120
await _retry(client, "deploy", {"env": "prod"}, token)
1118-
1119-
_assert_frozen_rejection(exc)
1120-
assert seen == []
1121+
_assert_frozen_rejection(exc)
1122+
assert seen == []
11211123

11221124

11231125
# -- lone surrogates: every encode on the state path is total ----------------------------
@@ -1185,7 +1187,7 @@ async def test_a_fractional_mint_instant_keeps_the_full_ttl(monkeypatch: pytest.
11851187
clock.now = _T0 + 2.6 # 0.6s after mint, past the ttl
11861188
with pytest.raises(MCPError) as exc:
11871189
await _retry(client, "deploy", {"env": "prod"}, late)
1190+
_assert_frozen_rejection(exc)
11881191

11891192
assert isinstance(second, CallToolResult)
1190-
_assert_frozen_rejection(exc)
11911193
assert seen == ["awaiting-confirm"]

0 commit comments

Comments
 (0)