Skip to content

fix(json): classify metadata carriers by kind - #77

Merged
denisvmedia merged 1 commit into
masterfrom
fix/json-empty-attribute-sentinels
Sep 26, 2026
Merged

denisvmedia merged 1 commit into
masterfrom
fix/json-empty-attribute-sentinels

Conversation

@denisvmedia

Copy link
Copy Markdown
Member

Description

Attaching errx.Attrs() or errx.FromAttrMap(nil) currently produces "sentinels":["(empty attribute list)"]. JSON now identifies attribute and trace carriers by their own type, so empty metadata no longer becomes a sentinel. Real sentinels remain visible beside empty metadata and when their parents carry attributes or traces.

Fixes #57

Type of Change

  • Bug fix (non-breaking API change)

Changes Made

  • Exclude classifications implementing Attrs() []errx.Attr or stacktrace.Tracer, including external implementations with empty payloads.
  • Preserve a sentinel's own text when its parent carries attributes or traces.
  • Keep displayable detection chain-wide; document this distinction in the helper and JSON README.
  • Replace the narrow empty-attributes test with a 56-case matrix covering classified, wrapped, standalone, and mixed errors. Assert exact sentinel lists, field omission, preserved messages, attributes, traces, and display text.

Testing

The regression matrix failed against master for empty metadata and sentinels with metadata parents, then passed with the fix.

  • go test -race -count=1 -coverprofile=/private/tmp/errx-57-coverage.out ./... — all packages pass; 95.4% overall, 93.7% JSON, 100% for isPureSentinel.
  • go test -race -count=1 ./json after the final fixture-only style adjustment.
  • go vet ./....
  • golangci-lint run --allow-serial-runners (local v2.14.0; CI pins v2.13.2).
  • govulncheck ./... — no vulnerabilities found.
  • go mod tidy -diff, gofmt, and git diff --check.

Documentation

Breaking Changes

No public signatures or JSON schema change. The intentional output corrections are:

  • Empty attribute/trace carriers contribute no sentinel text, including foreign classifications whose only content is their Error() text. A standalone carrier still retains that text in message.
  • A sentinel with an attributed or traced parent retains its own sentinel text. A displayable parent continues to exclude it, matching existing displayable behavior.

This does not add extraction support for external attribute providers; that remains separate from recognizing their kind.

Performance Impact

Two metadata traversal calls in isPureSentinel are replaced with direct interface checks. No quantified performance claim is made.

Checklist

  • Read CONTRIBUTING.md and followed project conventions.
  • Added regressions and completed local validation.
  • Updated documentation and changelog.

Copilot AI lite review requested due to automatic review settings September 26, 2026 16:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 39 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d0b2cebb-8a5a-454f-9a64-48b749cf6f88

📥 Commits

Reviewing files that changed from the base of the PR and between 962602e and 811082b.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • json/README.md
  • json/json.go
  • json/json_test.go
  • json/sentinel_kind_test.go

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.

@denisvmedia
denisvmedia added this pull request to the merge queue Sep 26, 2026
Merged via the queue into master with commit aa9ef7a Sep 26, 2026
4 checks passed
@denisvmedia
denisvmedia deleted the fix/json-empty-attribute-sentinels branch September 26, 2026 16:48
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.

json: empty attribute sets are serialized as a sentinel

2 participants