Skip to content

Preserve JSON RPC error codes and distinguish internal errors - #34

Open
SuhrudhC wants to merge 1 commit into
python-lsp:developfrom
SuhrudhC:fix/error-code-preservation
Open

SuhrudhC wants to merge 1 commit into
python-lsp:developfrom
SuhrudhC:fix/error-code-preservation

Conversation

@SuhrudhC

Copy link
Copy Markdown

Internal handler failures currently use -32602, the invalid parameters code. A received -32603 is consequently decoded as a generic exception. Separately, an application error with code 0 raises AttributeError during response handling and leaves the request Future unresolved.

Use -32603 for JsonRpcInternalError and distinguish an omitted code from an explicit zero in the exception constructor. Invalid parameter responses retain -32602. This follows JSON RPC 2.0 section 5.1.

Validation on Python 3.13.3 with pytest 9.2.0 and ujson 6.1.0:

  • All 35 tests pass. The unchanged suite has 27 tests.
  • Six of eight new cases fail against unchanged develop at a96d764d29cc17fbda52264e529f0803cda07fd8. The two controls pass.
  • Cases exercise direct, callable and Future handler failures, received internal and invalid parameter errors, and zero and nonzero application codes through the public Endpoint API.
  • Configured Pylint scores 10.00/10. Pycodestyle and Pyflakes pass.

The patch changes the exception constructor, one error code constant and adds tests. Cancellation and failed send cleanup candidates are separate. No live language server or hosted CI run is claimed.

Codex assisted with the source audit, implementation, tests and this description. No production incident, personal usage or independent human review is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant