codex icon indicating copy to clipboard operation
codex copied to clipboard

App-server misclassifies unknown methods and malformed parameters as invalid requests

Open dovvnloading opened this issue 2 weeks ago • 1 comments

Summary

A well-formed request naming an unavailable app-server method returns -32600 instead of -32601. Missing or incorrectly typed parameters for a known method also return -32600 instead of -32602. The Python SDK consequently raises InvalidRequestError for all three cases, preventing callers from distinguishing unsupported methods from invalid parameters by error type or code.

Reproduction

Start codex app-server --listen stdio://, initialize the connection, then send these newline-delimited requests:

{"id":1,"method":"initialize","params":{"clientInfo":{"name":"probe","version":"1"}}}
{"method":"initialized"}
{"id":2,"method":"nonexistent/method","params":{}}
{"id":3,"method":"thread/read","params":{}}
{"id":4,"method":"thread/loaded/list","params":{}}
{"id":5,"method":"thread/read","params":{"threadId":42}}
{"id":6,"method":"project/create","params":{"name":"","roots":[],"idempotencyKey":"test"}}

Wait for each response by ID; notifications can interleave.

Actual: The unknown method (id: 2) and both malformed parameter sets (id: 3 and id: 5) return -32600. The valid request (id: 4) succeeds. A separately validated invalid project name (id: 6) returns -32602. Through the Python SDK, the first three failures raise InvalidRequestError; the project validation failure raises InvalidParamsError.

Expected: Return -32601 for the unknown method and -32602 for missing or incorrectly typed parameters, allowing clients to handle unsupported operations and invalid parameters separately. The app-server uses a JSON-RPC-like protocol without the jsonrpc version field; its own error definitions and Python SDK already distinguish method-not-found from invalid-request. The JSON-RPC error-code table assigns these distinct meanings as well.

Reproduced with raw stdio requests and the Python SDK on Windows, CLI 0.167.2 and 0.170.0-alpha.2. Current source checked at c0cc9fc820f62e4dbdde68214dd6d792d6c8a7ee. #60740 shows an unsupported method in an extension workflow; this report concerns the generic error classification for any unknown method.

Possible fix

Distinguish an unrecognized method name from invalid parameters before mapping deserialization errors; return -32601 and -32602 respectively, and add regression tests for SDK exception mapping.

dovvnloading avatar Nov 12 '26 07:11 dovvnloading

I reproduced this on the official Linux codex-cli 0.168.0 release using a fresh synthetic Codex home and raw app-server stdio requests:

Request Observed response
Unknown nonexistent/method -32600
thread/read with no threadId -32600
thread/read with numeric threadId -32600
Valid thread/loaded/list Success
Experimental project/create with an empty name -32602

Initialization succeeded, responses matched their request IDs, and the app-server exited cleanly. The last case confirms that this release can return -32602 for a validated parameter error. The first three errors still share -32600, matching the Windows report.

This was a no-model, network-disabled local test. I did not test the Python SDK, a fix, or other platforms. Since the app-server protocol is JSON-RPC-like rather than strict JSON-RPC 2.0, could maintainers confirm whether unknown methods and malformed parameters should use distinct -32601 and -32602 codes?

TheOutlandsDev avatar Nov 13 '26 13:11 TheOutlandsDev