Skip to content

feat(core): add response-side JSON-RPC error code classifier#30

Merged
limehee merged 5 commits intomainfrom
feat/#24
Mar 11, 2026
Merged

feat(core): add response-side JSON-RPC error code classifier#30
limehee merged 5 commits intomainfrom
feat/#24

Conversation

@limehee
Copy link
Copy Markdown
Owner

@limehee limehee commented Mar 11, 2026

Summary

This PR adds a public error-code classification utility to jsonrpc-core and aligns response-side validation and samples with that API.

Main changes:

  • Added JsonRpcErrorClassifier for semantic classification of integer JSON-RPC error.code values
  • Added JsonRpcErrorCodeCategory with:
    • STANDARD
    • SERVER_RESERVED_RANGE
    • CUSTOM
  • Added DefaultJsonRpcErrorClassifier as the default implementation
  • Refactored DefaultJsonRpcResponseValidator to reuse the classifier for:
    • STANDARD_ONLY
    • STANDARD_OR_SERVER_ERROR_RANGE
  • Kept CUSTOM_RANGE as a direct numeric bounds check, independent of classifier category
  • Added boundary and policy regression tests, including explicit STANDARD_ONLY rejection for custom codes
  • Expanded the pure Java response-side sample to show parsed response validation plus error-code classification
  • Updated README and protocol/pure-Java guides to document the new response-side utility

Related Issues

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Test
  • Build/CI

JSON-RPC Impact

Describe protocol-level impact, if any:

  • No protocol behavior change
  • Request validation behavior changed
  • Error mapping behavior changed
  • Method registration/dispatch behavior changed

Details:

  • This PR adds a reusable response-side utility for interpreting integer error.code values.
  • Existing response validation policies remain the same in behavior.
  • CUSTOM_RANGE still validates against configured numeric bounds rather than classifier category.
  • CUSTOM classification does not mean invalid; it means the code is outside the standard set and the reserved server range.

Validation

  • ./gradlew test
  • ./gradlew check
  • Added/updated tests for new behavior

Additional verification performed:

  • ./gradlew :jsonrpc-core:test --tests 'com.limehee.jsonrpc.core.DefaultJsonRpcErrorClassifierTest' --tests 'com.limehee.jsonrpc.core.DefaultJsonRpcResponseValidatorTest' --no-daemon
  • ./gradlew -p samples/pure-java-demo test --no-daemon

Documentation

  • Updated README (if needed)
  • Added migration notes for breaking changes (if any)

Notes:

  • No breaking migration is required.
  • The pure Java sample now demonstrates both response validation and semantic error-code classification.
  • The protocol guide now explicitly documents standard codes, the reserved server range, and custom codes.

@limehee limehee self-assigned this Mar 11, 2026
@limehee limehee changed the title feat(core): add JSON-RPC error code classifier feat(core): add response-side JSON-RPC error code classifier Mar 11, 2026
@limehee limehee added the type: feature New feature specification and implementation. label Mar 11, 2026
@limehee limehee merged commit 2e6bb45 into main Mar 11, 2026
5 checks passed
@limehee limehee deleted the feat/#24 branch March 11, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature New feature specification and implementation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add JsonRpcErrorClassifier for standardized error code interpretation

1 participant