[2.x] test: Add test for error response to unknown JSON-RPC method

This test fails against the current code — the server silently drops
requests with unknown methods instead of responding with an error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Brian Hotopp 2026-03-31 12:51:34 -04:00
parent 7218b2a1ac
commit 4f01a75887
1 changed files with 10 additions and 0 deletions

View File

@ -79,6 +79,16 @@ class ResponseTest extends AbstractServerTest {
}
}
test("unknown method returns error") {
val id = svr.session.nextId()
svr.session.sendJsonRpc(id, "build/foo", "{}").get
val response = svr.session.waitForResponseMsg(10.seconds, id).get
assert(
response.error.exists(_.code == -32601),
s"Expected method-not-found error, got: $response"
)
}
private def neverReceiveResponse(
duration: FiniteDuration
)(predicate: sbt.internal.protocol.JsonRpcResponseMessage => Boolean): Unit =