fix: domain prefix dispatch + application error for service methods #2

Merged
mik-tf merged 1 commit from development_fix_service_error_dispatch into development 2026-03-02 16:58:15 +00:00
Owner

Summary

Two fixes for the JSON-RPC dispatch layer:

1. Domain prefix for 3-part dispatch (Fixes #3)

  • RPC client rpc_call now correctly prefixes method names with domain. for 3-part dispatch (domain.Type.method)
  • Without this, Unix socket transport method routing fails

2. Application error for service method failures (Fixes #1)

  • Service method errors (wrong password, expired token, etc.) were incorrectly reported as -32601 Method not found
  • Added application_error() constructor to JsonRpcError using code -32000 (JSON-RPC server error range)
  • Changed dispatch_to_handler to use application_error instead of method_not_found for handle_service_call failures
  • Affects all domains — any service method error now shows the actual error message to clients

Test plan

  • cargo check passes
  • Login with wrong password returns RPC error [-32000]: Authentication failed instead of RPC error [-32601]: Method not found
  • Login with correct password still works
  • Other service method errors (expired challenge, etc.) show actual message
  • Unix socket transport correctly routes 3-part method names
## Summary Two fixes for the JSON-RPC dispatch layer: ### 1. Domain prefix for 3-part dispatch (Fixes #3) - RPC client `rpc_call` now correctly prefixes method names with `domain.` for 3-part dispatch (`domain.Type.method`) - Without this, Unix socket transport method routing fails ### 2. Application error for service method failures (Fixes #1) - Service method errors (wrong password, expired token, etc.) were incorrectly reported as `-32601 Method not found` - Added `application_error()` constructor to `JsonRpcError` using code `-32000` (JSON-RPC server error range) - Changed `dispatch_to_handler` to use `application_error` instead of `method_not_found` for `handle_service_call` failures - Affects all domains — any service method error now shows the actual error message to clients ## Test plan - [x] `cargo check` passes - [ ] Login with wrong password returns `RPC error [-32000]: Authentication failed` instead of `RPC error [-32601]: Method not found` - [ ] Login with correct password still works - [ ] Other service method errors (expired challenge, etc.) show actual message - [ ] Unix socket transport correctly routes 3-part method names
Service methods (authservice.login, etc.) go through handle_service_call
in the dispatch layer. When they return application errors (wrong password,
expired token, etc.), dispatch.rs incorrectly wrapped them as -32601
"Method not found". This made it impossible for clients to see the actual
error message.

Now uses a new application_error() constructor with code -32000 (JSON-RPC
server error range) that puts the actual error message in the message field.

Fixes #1

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mik-tf force-pushed development_fix_service_error_dispatch from 1c9f8596a2 to 0ae498c0d7 2026-03-01 14:20:16 +00:00 Compare
mik-tf changed title from fix: application error dispatch for service methods to fix: domain prefix dispatch + application error for service methods 2026-03-01 14:21:00 +00:00
mik-tf merged commit 3d0251da28 into development 2026-03-02 16:58:15 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_rpc!2
No description provided.