Skip to content

fix: Use FromContext(any) for multi-context retrieval in paseto, newrelic, and sentry#1724

Merged
gaby merged 7 commits into
update-contrib-modules-to-use-fromcontextfrom
copilot/sub-pr-1721
Mar 2, 2026
Merged

fix: Use FromContext(any) for multi-context retrieval in paseto, newrelic, and sentry#1724
gaby merged 7 commits into
update-contrib-modules-to-use-fromcontextfrom
copilot/sub-pr-1721

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 28, 2026

  • Remove *AnyContext helpers — FromContext, GetHubFromContext, MustGetHubFromContext each accept any
  • Update tests to call context helpers directly with c.Context()
  • Update READMEs (paseto, sentry, newrelic) for new (ctx any) signatures
  • Fix newrelic README to use *nr.Transaction consistently with the alias in the signature block
  • Update jwt README with alias comment and return type description (consistent with newrelic/sentry pattern)
  • Standardize FromContext description phrasing across all READMEs (paseto, newrelic, sentry, jwt)

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…eto, newrelic, sentry

Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 28, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • collector.newrelic.com
    • Triggering command: /tmp/go-build2399329134/b275/newrelic.test /tmp/go-build2399329134/b275/newrelic.test -test.paniconexit0 -test.count=1 -test.timeout=1m0s go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build2399329134/b285/importcfg -pack /home/REDACTED/go/pkg/mod/golang.org/x/net@v0.51.0/trace/events.go /home/REDACTED/go/pkg/mod/golang.org/x/net@v0.51.0/trace/histogram.go abis�� ity/connectivity-p rg/toolchain@v0.google.golang.org/grpc/peer ux-amd64/pkg/tool/linux_amd64/vet --depth 8 m ux-amd64/pkg/too-trimpath (dns block)
    • Triggering command: /tmp/go-build882747594/b275/newrelic.test /tmp/go-build882747594/b275/newrelic.test -test.paniconexit0 -test.timeout=10m0s -test.count=1 -test.v=true rg/toolchain@v0.-p m 0.1-go1.25.0.lin-lang=go1.25 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Fix middleware locals storage in request context fix: Restore original fiber.Ctx signatures; add *AnyContext helpers for multi-context retrieval Feb 28, 2026
@ReneWerner87 ReneWerner87 added ☢️ Bug Something isn't working 📝 Proposal labels Feb 28, 2026
@gaby
Copy link
Copy Markdown
Member

gaby commented Feb 28, 2026

@copilot we only want to support FromContext with any, you do not need to add another helper.

Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot we only want to support FromContext with any, you do not need to add another helper.

Done in commit 23c5b92. Removed all *AnyContext helpers — FromContext, GetHubFromContext, and MustGetHubFromContext now each accept any directly, supporting fiber.Ctx, fiber.CustomCtx, *fasthttp.RequestCtx, and context.Context. READMEs updated accordingly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • collector.newrelic.com
    • Triggering command: /tmp/go-build3506980738/b275/newrelic.test /tmp/go-build3506980738/b275/newrelic.test -test.paniconexit0 -test.count=1 -test.timeout=1m0s go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build3506980738/b319/importcfg -pack /home/REDACTED/go/pkg/mod/google.golang.org/grpc@v1.79.1/balancer/pickfirst/pickfirst.go ux-amd64/pkg/too-trimpath abis�� rg/toolchain@v0.-p credential.helpegoogle.golang.org/grpc/keepalive ux-amd64/pkg/tool/linux_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title fix: Restore original fiber.Ctx signatures; add *AnyContext helpers for multi-context retrieval fix: Use FromContext(any) for multi-context retrieval in paseto, newrelic, and sentry Feb 28, 2026
@gaby gaby marked this pull request as ready for review February 28, 2026 16:44
@gaby gaby requested a review from a team as a code owner February 28, 2026 16:44
@gaby gaby requested review from ReneWerner87, Copilot, efectn, gaby and sixcolors and removed request for a team February 28, 2026 16:44
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

This PR updates context-retrieval helper APIs in the paseto, newrelic, and sentry middlewares to accept any, enabling value retrieval from multiple context types (e.g., fiber.Ctx vs c.Context() when PassLocalsToContext is enabled), and adjusts README/docs accordingly.

Changes:

  • Document/clarify GetHubFromContext / MustGetHubFromContext behavior in sentry (panic semantics).
  • Document newrelic.FromContext(ctx any) as supporting multiple context types.
  • Disambiguate README “Signature” sections using package aliases to avoid confusion with upstream SDK packages.

Reviewed changes

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

File Description
v3/sentry/sentry.go Adds explicit doc note that MustGetHubFromContext panics when hub is missing.
v3/sentry/README.md Updates signature docs to disambiguate middleware package vs Sentry SDK types.
v3/newrelic/fiber.go Updates FromContext doc comment to note supported context types.
v3/newrelic/README.md Updates signature docs/examples with aliases; clarifies PassLocalsToContext retrieval.

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

Comment thread v3/newrelic/README.md Outdated
@gaby
Copy link
Copy Markdown
Member

gaby commented Feb 28, 2026

@copilot double check all the docs again.

…alias

Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot double check all the docs again.

Done in commit 4d6722c. The only inconsistency across all three READMEs was *newrelic.Transaction vs *nr.Transaction in the newrelic README — that's now fixed. Everything else (paseto, sentry) looks correct.

@gaby
Copy link
Copy Markdown
Member

gaby commented Feb 28, 2026

@copilot make sure every model using FromContext had their docs updated

…n for FromContext

Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot make sure every model using FromContext had their docs updated

Done in commit 90953bf. The jwt package was the only one missing docs — its README now has the // jwt "github.com/golang-jwt/jwt/v5" alias comment in the signature block and a prose description of the return type, consistent with the newrelic and sentry READMEs. All four modules (paseto, newrelic, sentry, jwt) now have fully updated FromContext docs.

@gaby
Copy link
Copy Markdown
Member

gaby commented Feb 28, 2026

@copilot also check the docs for otel and jwt.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Feb 28, 2026

@copilot also check the docs for otel and jwt.

Checked both:

  • jwt: Already updated in commit 90953bf — the signature block has the // jwt "github.com/golang-jwt/jwt/v5" alias comment and the prose description mentions the return type.
  • otel: Has no FromContext-style helper to document. It stores a tracer internally via a private key, and exposes spans to callers through the standard OTel API (oteltrace.SpanFromContext(c.Context())). The otel README's Signature section is correct as-is.

All modules that expose a FromContext-style helper (paseto, newrelic, sentry, jwt) now have updated docs.

@gaby
Copy link
Copy Markdown
Member

gaby commented Mar 1, 2026

@copilot in each readme, be consistent about this part:

`FromContext` accepts a `fiber.Ctx`, `fiber.CustomCtx`, `*fasthttp.RequestCtx`, or a standard `context.Context` (e.g. the value returned by `c.Context()` when `PassLocalsToContext` is enabled)

You have the same messages in different ways across README files; it should be the same as above instead.

Co-authored-by: gaby <835733+gaby@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 1, 2026

@copilot in each readme, be consistent about this part:

...

Fixed in commit f330648. The paseto README had a different phrasing at the FromContext usage section — it now uses the canonical sentence consistently across all READMEs (paseto, newrelic, sentry, jwt).

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


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

Comment thread v3/sentry/sentry.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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

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


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

Comment thread v3/sentry/README.md
Comment thread v3/newrelic/README.md
Comment thread v3/jwt/README.md
@gaby gaby merged commit 673ec1a into update-contrib-modules-to-use-fromcontext Mar 2, 2026
14 checks passed
@gaby gaby deleted the copilot/sub-pr-1721 branch March 2, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working 📝 Proposal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants