Skip to content

fix(errorsx): report the caller of the error handler - #5547

Merged
chrisgacsal merged 1 commit into
mainfrom
fix/errorsx-log-caller
Nov 18, 2026
Merged

chrisgacsal merged 1 commit into
mainfrom
fix/errorsx-log-caller

Conversation

@chrisgacsal

@chrisgacsal chrisgacsal commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Overview

Errors logged through errorsx.SlogHandler showed pkg/errorsx/handler.go in the JSON log's caller field. Capture the file and line that called Handle or HandleContext so the log points to the code reporting the error.

Notes for reviewer

TestSlogHandlerCaller checks the exact file and line for both entry points. It failed against the previous implementation and passes with this change.

Tested with go test -tags=dynamic ./pkg/errorsx ./pkg/framework/transport/httptransport.

Summary by CodeRabbit

  • Bug Fixes
    • Cancellation errors are now reported as warnings when appropriate, while other errors retain their existing severity.
    • Error logs now include the caller’s source location and diagnostic details when available.

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge.

Summary

Updates SlogHandler to report the code that called Handle or HandleContext, rather than the handler itself.

  • Error logs now point to the code that reported them.

Reviews (1) · Last reviewed commit: "fix(errorsx): report the caller of the e..." · Reviewed by Greptile

@chrisgacsal
chrisgacsal requested a review from a team as a code owner November 16, 2026 14:54
@chrisgacsal chrisgacsal added the release-note/bug-fix Release note: Bug Fixes label Nov 16, 2026
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

SlogHandler.Handle and HandleContext now use a shared record-based logger. A test checks that each method records its caller’s file and line.

Changes: Slog error handling

Layer / File(s) Summary
Record-based logging and caller validation
pkg/errorsx/handler.go, pkg/errorsx/handler_test.go
Handle and HandleContext share logic that selects the log level and writes a timestamped record with caller details and diagnostic attributes. The new test checks the caller’s file and line in both methods’ JSON log records.

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

Change: Bug fix

Suggested labels: kind/bug

Suggested reviewers: galexihu, turip

Merge Risk: Minimal · up to e41c1

This change makes errors logged through the error handler report the file and line of the code that called it, instead of the handler's own file. The change is small and has a test for both entry points. I found no merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: the error handler now reports the caller's file and line instead of pkg/errorsx/handler.go. The raw summary confirms Handle and HandleContext capture the call site, an…
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: Title check

Explanation

The title names the main change: the error handler now reports the caller's file and line instead of pkg/errorsx/handler.go. The raw summary confirms Handle and HandleContext capture the call site, and the test file adds TestSlogHandlerCaller to verify it. The title is specific and matches the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 890e6dc and e41c16a.

Files selected for processing: 2

  • pkg/errorsx/handler.go
  • pkg/errorsx/handler_test.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@chrisgacsal chrisgacsal self-assigned this Nov 16, 2026
@chrisgacsal
chrisgacsal requested a review from turip November 16, 2026 14:56
@chrisgacsal
chrisgacsal merged commit 2fad17d into main Nov 18, 2026
33 of 35 checks passed
@chrisgacsal
chrisgacsal deleted the fix/errorsx-log-caller branch November 18, 2026 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/bug-fix Release note: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants