Skip to content

fix: change User and Tenant param type to ...any#36

Merged
samber merged 2 commits intosamber:mainfrom
cley44:fix-user-tenant-wrong-type
Apr 6, 2026
Merged

fix: change User and Tenant param type to ...any#36
samber merged 2 commits intosamber:mainfrom
cley44:fix-user-tenant-wrong-type

Conversation

@cley44
Copy link
Copy Markdown
Contributor

@cley44 cley44 commented Nov 25, 2024

Hey 👋,

oops.User() only accept map[string]any as second argument but the underlying function is expecting ...any (chain of key/value)

This is the same for oops.Tenant()

This result in this code working

oops.Hint("test").User("userID", "firstname", "John")

But this code does not

// Too many arguments in call to 'oops.User'
oops.User("userID", "firstname", "John")
// Is accepted but doesn't add firstname to user
oops.User("userID", map[string]any{
	"firstname": "John"
})

@samber
Copy link
Copy Markdown
Owner

samber commented Feb 23, 2025

Warning: it might cause a breaking change.

I suggest 3 interpretations of the parameters:

  • oops.User(userID, slog.Attr...)
  • oops.User(userID, key string1, value1 any, key2 string, value2 any...)
  • oops.User(userID, kv map[string]any....)

Please check the implem of slog.Group or slog.With, which is similar.

@cley44 cley44 force-pushed the fix-user-tenant-wrong-type branch from 5ad28fb to 463623e Compare March 14, 2026 18:49
@cley44 cley44 force-pushed the fix-user-tenant-wrong-type branch from 463623e to a0a1027 Compare March 14, 2026 18:51
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 67.85714% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.30%. Comparing base (1a99714) to head (3179427).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
builder.go 73.07% 14 Missing ⚠️
oops.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #36      +/-   ##
==========================================
- Coverage   85.08%   84.30%   -0.78%     
==========================================
  Files          14       14              
  Lines         972     1013      +41     
==========================================
+ Hits          827      854      +27     
- Misses        119      133      +14     
  Partials       26       26              
Flag Coverage Δ
unittests 84.30% <67.85%> (-0.78%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the oops.User and oops.Tenant helpers to accept variadic attribute inputs (matching the underlying builder API), and enhances attribute parsing to support additional structured input forms.

Changes:

  • Change oops.User(...) / oops.Tenant(...) signatures from map[string]any to ...any.
  • Extend builder parsing to support map[string]any and slog.Attr (including slog.Group) in user/tenant attributes.
  • Update README examples and add test cases covering slog.Attr + mixed argument forms for user attributes.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
README.md Updates API documentation and examples for the new User/Tenant attribute formats.
oops.go Changes top-level User/Tenant function signatures to ...any and forwards args to the builder.
builder.go Introduces shared argument-to-map conversion supporting slog.Attr, map[string]any, and string key/value pairs.
oops_test.go Adds tests for User(...) using slog.Attr/slog.Group and mixed map + key/value arguments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread README.md
Comment thread builder.go
Comment thread builder.go Outdated
Comment thread builder.go
Comment thread README.md
Comment thread README.md Outdated
@samber
Copy link
Copy Markdown
Owner

samber commented Apr 6, 2026

Congrats on this first OSS PR ;)

I'm going to fix linter errors in a different PR. (not linked to your work)

@samber samber merged commit 3100ff3 into samber:main Apr 6, 2026
13 of 16 checks passed
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