Skip to content

Lift app-server JSON-RPC error handling to request boundary#19484

Merged
pakrym-oai merged 2 commits intomainfrom
pakrym/streamline-appserver-error-handling
Apr 26, 2026
Merged

Lift app-server JSON-RPC error handling to request boundary#19484
pakrym-oai merged 2 commits intomainfrom
pakrym/streamline-appserver-error-handling

Conversation

@pakrym-oai
Copy link
Copy Markdown
Collaborator

@pakrym-oai pakrym-oai commented Apr 25, 2026

Why

App-server request handling had a lot of repeated JSON-RPC error construction and one-off send_error/return branches. This made small handlers noisy and pushed error response details into leaf code that otherwise only needed to validate input or call the underlying API.

What Changed

  • Added shared JSON-RPC error constructors in codex-rs/app-server/src/error_code.rs.
  • Lifted straightforward request result emission into codex-rs/app-server/src/message_processor.rs so response/error dispatch happens at the request boundary.
  • Reused the result helpers across command exec, config, filesystem, device-key, external-agent config, fs-watch, and outgoing-message paths.
  • Removed leaf wrapper handlers where the method body was only forwarding to a response helper.
  • Returned request validation errors upward in the simple cases instead of sending an error locally and immediately returning.

Verification

  • cargo test -p codex-app-server --lib command_exec::tests
  • cargo test -p codex-app-server --lib outgoing_message::tests
  • cargo test -p codex-app-server --lib in_process::tests
  • cargo test -p codex-app-server --test all v2::fs
  • cargo test -p codex-app-server --test all v2::config_rpc
  • cargo test -p codex-app-server --test all v2::external_agent_config
  • cargo test -p codex-app-server --test all v2::initialize
  • just fix -p codex-app-server
  • git diff --check

Note: full cargo test -p codex-app-server was attempted and stopped in message_processor::tracing_tests::turn_start_jsonrpc_span_parents_core_turn_spans with a stack overflow after unrelated tests had already passed.

@pakrym-oai pakrym-oai changed the title Refactor app-server error handling to reduce boilerplate Lift app-server JSON-RPC error handling to request boundary Apr 25, 2026
@pakrym-oai pakrym-oai marked this pull request as ready for review April 25, 2026 04:00
@pakrym-oai pakrym-oai merged commit 2a020f1 into main Apr 26, 2026
25 checks passed
@pakrym-oai pakrym-oai deleted the pakrym/streamline-appserver-error-handling branch April 26, 2026 22:10
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants