Skip to content

feat(errconnect): add connect-go error code mapping - #25

Merged
yordis merged 1 commit into
mainfrom
yordis/feat-add-errconnect-package
Sep 5, 2026
Merged

feat(errconnect): add connect-go error code mapping#25
yordis merged 1 commit into
mainfrom
yordis/feat-add-errconnect-package

Conversation

@yordis

@yordis yordis commented Sep 5, 2026

Copy link
Copy Markdown
Member
  • Services adopting Connect RPC need to translate trogonerror codes into connect.Code, but not every consumer of this module uses Connect and shouldn't pay for the dependency.
  • Kept as a subpackage in the same module (not a nested go.mod) so the project stays on a single version and release-please only tracks one component; Go still only compiles/links errconnect for callers who actually import it.

Services adopting Connect RPC need to translate trogonerror codes into
connect.Code without every consumer of the root module paying for the
connect-go dependency.

Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@cursor

cursor Bot commented Sep 5, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Isolated new subpackage and explicit error-code mapping with tests; no changes to core trogonerror behavior.

Overview
Adds an optional errconnect subpackage so Connect RPC handlers can translate trogonerror.Code into connect.Code without forcing every module consumer to depend on Connect.

errconnect.Code uses an explicit switch over the canonical gRPC status codes (including the Canceled spelling mismatch) instead of a numeric cast, and maps any unrecognized code to connect.CodeInternal so future enum drift cannot silently mislabel errors.

Tests cover each known code plus the unknown-code fallback. go.mod gains connectrpc.com/connect for builds that import errconnect; callers that only use the root package are unchanged at link time.

Reviewed by Cursor Bugbot for commit be49391. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 1ad722c0-f291-4002-8b18-1e9658bfbb33

📥 Commits

Reviewing files that changed from the base of the PR and between 4f9f6d4 and be49391.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • errconnect/code.go
  • errconnect/code_test.go
  • go.mod

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The PR adds an errconnect.Code function that maps trogonerror.Code values to ConnectRPC codes. It adds a fallback for unknown values, tests all mappings, and declares the ConnectRPC dependency.

Changes

Connect error-code mapping

Layer / File(s) Summary
Error-code mapping implementation
errconnect/code.go, go.mod
The new Code function maps all 16 canonical codes and returns connect.CodeInternal for unknown values. connectrpc.com/connect is added as a direct dependency.
Mapping validation
errconnect/code_test.go
Table-driven tests cover every defined mapping and the unknown-code fallback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to be493

This adds Connect RPC status-code conversion for existing errors, with unknown values safely reported as Internal. The implementation and dependency update are ready to merge.

Poem

A rabbit hops through codes so neat
Each error finds its matching seat
Unknown paths turn Internal gray
Tests guard every mapped way
Connect joins the burrow bright
All sixteen paths now track just right

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding Connect RPC error-code mapping in the errconnect package.
Description check ✅ Passed The description explains the errconnect subpackage, dependency isolation, and single-module design. It directly relates to the changeset and objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yordis/feat-add-errconnect-package

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yordis
yordis merged commit b17fb03 into main Sep 5, 2026
4 checks passed
@yordis
yordis deleted the yordis/feat-add-errconnect-package branch September 5, 2026 08:25
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