Skip to content

Comments

fix: render error types as strings in human log sink#224

Merged
dannykopping merged 1 commit intomainfrom
dk/err-formatting
Feb 23, 2026
Merged

fix: render error types as strings in human log sink#224
dannykopping merged 1 commit intomainfrom
dk/err-formatting

Conversation

@dannykopping
Copy link
Contributor

Summary

  • formatValue in entryhuman checked reflect.Struct before the error interface, so struct-typed errors (e.g. context.DeadlineExceeded) were JSON-marshaled as {} instead of their .Error() string.
  • Added error/fmt.Stringer type check before the struct/map path, matching the existing pattern in map.go:encode().

Test plan

  • Added TestContextErrorFormatting in entryhuman covering DeadlineExceeded, Canceled, and wrapped errors
  • Added TestContextErrors in slogjson for end-to-end coverage
  • Added contextDeadlineExceeded/contextCanceled cases in TestMap

🤖 Generated with Claude Code

@coveralls
Copy link

coveralls commented Feb 23, 2026

Pull Request Test Coverage Report for Build 50d5187765f31c6188695fe1e5f9dbc17378f68f-PR-224

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 96.026%

Totals Coverage Status
Change from base Build 348ac12d311d4fc6467ccaf97feec1525e071b29: 0.01%
Covered Lines: 894
Relevant Lines: 931

💛 - Coveralls

@dannykopping dannykopping force-pushed the dk/err-formatting branch 6 times, most recently from 028fb71 to e694146 Compare February 23, 2026 12:31
`formatValue` checked `reflect.Struct` before checking the `error`
interface, so struct-typed errors like `context.DeadlineExceeded`
were serialized via `json.Marshal` as `{}` instead of their error
string.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dannykopping dannykopping marked this pull request as ready for review February 23, 2026 12:35
@dannykopping dannykopping merged commit 284c50f into main Feb 23, 2026
1 check passed
@dannykopping dannykopping deleted the dk/err-formatting branch February 23, 2026 15:30
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.

3 participants