Skip to content

[codex] Fix false positives for JsonRpcErrorCode comparisons#192

Closed
ded-furby wants to merge 1 commit into
cyanheads:mainfrom
ded-furby:codex/fix-error-contract-enum-comparison
Closed

[codex] Fix false positives for JsonRpcErrorCode comparisons#192
ded-furby wants to merge 1 commit into
cyanheads:mainfrom
ded-furby:codex/fix-error-contract-enum-comparison

Conversation

@ded-furby
Copy link
Copy Markdown

Summary

  • scope JsonRpcErrorCode.X detection in lintErrorContractConformance to throw new McpError(...) sites instead of any enum reference in the handler source
  • add a regression test covering err.code === JsonRpcErrorCode.NotFound followed by ctx.fail(...)

Root cause

The conformance heuristic treated every JsonRpcErrorCode.X token as a direct throw, so comparison logic inside catch/switch flows triggered error-contract-prefer-fail even when the handler routed correctly through ctx.fail(...).

Validation

  • bunx vitest run --project unit tests/unit/linter/error-contract-rules.test.ts
  • bunx vitest run --project unit tests/unit/linter/*.test.ts

Closes #191.

@cyanheads
Copy link
Copy Markdown
Owner

Thanks for the PR! We landed the same fix in v0.9.20 (#191) — scoped the scan to new McpError(JsonRpcErrorCode.X) construction (matching the prefer-error-factory rule, so it also covers the assign-then-throw case) plus a docs update. Closing since it is already shipped.

@cyanheads cyanheads closed this Jun 2, 2026
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.

bug(linter): error-contract conformance counts JsonRpcErrorCode comparisons as direct throws

2 participants