Skip to content

feat!: add support for Echo v5#1183

Merged
giortzisg merged 2 commits intogetsentry:masterfrom
Scorfly:bump-echo-middleware
Apr 2, 2026
Merged

feat!: add support for Echo v5#1183
giortzisg merged 2 commits intogetsentry:masterfrom
Scorfly:bump-echo-middleware

Conversation

@Scorfly
Copy link
Copy Markdown
Contributor

@Scorfly Scorfly commented Jan 24, 2026

BREAKING CHANGE: echo integration now requires github.com/labstack/echo/v5 and Go 1.25. Echo v4 is no longer supported.

Dependency and module

  • Bump github.com/labstack/echo from v4.10.1 to v5.0.0.
  • Set go directive to 1.25.0 in echo/go.mod.
  • Drop Echo v4-only indirects (gommon, go-colorable, go-isatty, bytebufferpool, fasttemplate, x/crypto, x/net) and update remaining (x/sys, x/text). go.sum updated accordingly.

Echo v5 API adjustments

  • Use *echo.Context instead of echo.Context in handler and public API (GetHubFromContext, SetHubOnContext, GetSpanFromContext) to match v5’s pointer-based Context.
  • Update all handler signatures in code and docs from func(c echo.Context) error to func(c *echo.Context) error.
  • In v5, Context.Response() returns http.ResponseWriter, not *Response, so ctx.Response().Status is no longer available.

HTTP status and Response handling

  • Replace direct ctx.Response().Status with echo.UnwrapResponse(ctx.Response()) to obtain *echo.Response and use resp.Status when UnwrapResponse succeeds and resp.Status != 0.
  • When UnwrapResponse fails (e.g. middleware replaces the response with a writer that does not unwrap to *echo.Response), leave status at its zero value (0) instead of defaulting to 200.
  • For handler-returned errors, use echo.HTTPStatusCoder instead of *echo.HTTPError so that both *HTTPError and unexported *httpError (ErrNotFound, ErrMethodNotAllowed, etc.) are handled and the correct status is used for the transaction.

Tests

  • In TestIntegration, skip route registration when Handler is nil so the “404 / no route” case does not call router.GET("", nil). Echo v5’s router rejects Handler == nil and panics with “adding route without handler function”.
  • Add TestUnwrapResponseError: when the response is wrapped by a writer that does not implement Unwrap() (e.g. &struct{ http.ResponseWriter }{}), UnwrapResponse returns an error; the middleware must not panic and must record http.response.status_code as 0 in the transaction.

Documentation and examples

  • README.md and example_test.go: switch imports and examples from echo/v4 to echo/v5 and from echo.Context to *echo.Context.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 24, 2026

Semver Impact of This PR

🔴 Major (breaking changes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Breaking Changes 🛠

  • Add support for Echo v5 by Scorfly in #1183

New Features ✨

  • Add IsSensitiveHeader helper to easily distinguish which headers to scrub for PII. by giortzisg in #1239

Bug Fixes 🐛

  • (ci) Update validate-pr action to remove draft enforcement by stephanie-anderson in #1237

Internal Changes 🔧

Deps

  • Bump changelog-preview.yml from 2.24.1 to 2.25.2 by dependabot in #1247
  • Bump getsentry/craft from 2.24.1 to 2.25.2 by dependabot in #1248
  • Bump codecov/codecov-action from 5.5.2 to 6.0.0 by dependabot in #1245
  • Bump actions/create-github-app-token from 2.2.1 to 3.0.0 by dependabot in #1246
  • Bump actions/setup-go from 6.3.0 to 6.4.0 by dependabot in #1244

Other

  • (otel) Bump OpenTelemetry SDK to 1.40.0 by giortzisg in #1243
  • Update validate-pr workflow by stephanie-anderson in #1242
  • Add PR validation workflow by stephanie-anderson in #1234

🤖 This preview updates automatically when you update the PR.

@giortzisg
Copy link
Copy Markdown
Contributor

Hey @Scorfly, we can't really support this right now, since the module versioning needs to be consistent across packages, and we also want to support the three latest go versions.

@j0nimost
Copy link
Copy Markdown

This is quite unprecedented. Upgrading to echo/v5 while using Sentry is causing problems.

@giortzisg
Copy link
Copy Markdown
Contributor

We already had some discussions internally about upgrading go versions for the integrations separately to the main sdk, so we will support v5.

@giortzisg
Copy link
Copy Markdown
Contributor

Hey @Scorfly, I updated the ci to allow bumping echo to 1.25. You can update the branch and we can merge the change.

@Scorfly
Copy link
Copy Markdown
Contributor Author

Scorfly commented Mar 4, 2026

Thx !
I'm not available now, so I'll probably do it this week-end.

@Scorfly Scorfly force-pushed the bump-echo-middleware branch 2 times, most recently from 18eefef to 1a3f0e9 Compare March 7, 2026 20:24
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.28%. Comparing base (1ce3436) to head (8b9b819).
⚠️ Report is 72 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1183      +/-   ##
==========================================
- Coverage   86.04%   82.28%   -3.76%     
==========================================
  Files          62       75      +13     
  Lines        6090     7272    +1182     
==========================================
+ Hits         5240     5984     +744     
- Misses        635     1018     +383     
- Partials      215      270      +55     

☔ 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.

defer func() {
status := ctx.Response().Status
var status int
if resp, err := echo.UnwrapResponse(ctx.Response()); err == nil && resp.Status != 0 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should skip setting http.response.status_code if Status = 0. Also let's add a debug statement that we couldn't get the response status code.

@giortzisg
Copy link
Copy Markdown
Contributor

Overall looks good, let's just amend the comment.

Just FYI, we will release this after 31-03, as per the recommendation here

@Scorfly Scorfly force-pushed the bump-echo-middleware branch from 1a3f0e9 to f8d2c97 Compare March 11, 2026 19:59
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

BREAKING CHANGE: echo integration now requires github.com/labstack/echo/v5
and Go 1.25. Echo v4 is no longer supported.

- Bump github.com/labstack/echo from v4.10.1 to v5.0.0.
- Set go directive to 1.25.0 in echo/go.mod.
- Drop Echo v4-only indirects (gommon, go-colorable, go-isatty,
  bytebufferpool, fasttemplate, x/crypto, x/net) and update remaining
  (x/sys, x/text). go.sum updated accordingly.

- Use *echo.Context instead of echo.Context in handler and public API
  (GetHubFromContext, SetHubOnContext, GetSpanFromContext) to match
  v5’s pointer-based Context.
- Update all handler signatures in code and docs from
  `func(c echo.Context) error` to `func(c *echo.Context) error`.
- In v5, Context.Response() returns http.ResponseWriter, not *Response,
  so ctx.Response().Status is no longer available.

- Replace direct ctx.Response().Status with echo.UnwrapResponse(ctx.Response())
  to obtain *echo.Response and use resp.Status when UnwrapResponse succeeds
  and resp.Status != 0.
- When UnwrapResponse fails (e.g. middleware replaces the response with a
  writer that does not unwrap to *echo.Response), leave status at its zero
  value (0) instead of defaulting to 200.
- For handler-returned errors, use echo.HTTPStatusCoder instead of
  *echo.HTTPError so that both *HTTPError and unexported *httpError
  (ErrNotFound, ErrMethodNotAllowed, etc.) are handled and the correct
  status is used for the transaction.

- In TestIntegration, skip route registration when Handler is nil so the
  “404 / no route” case does not call router.GET("", nil). Echo v5’s
  router rejects Handler == nil and panics with “adding route without
  handler function”.
- Add TestUnwrapResponseError: when the response is wrapped by a writer
  that does not implement Unwrap() (e.g. &struct{ http.ResponseWriter }{}),
  UnwrapResponse returns an error; the middleware must not panic and must
  record http.response.status_code as 0 in the transaction.

- README.md and example_test.go: switch imports and examples from
  echo/v4 to echo/v5 and from echo.Context to *echo.Context.
@Scorfly Scorfly force-pushed the bump-echo-middleware branch from f8d2c97 to 535b494 Compare March 11, 2026 22:08
Copy link
Copy Markdown
Contributor

@giortzisg giortzisg left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @Scorfly 🚀

@giortzisg giortzisg changed the title feat(echo): add support for Echo v5 feat!(echo): add support for Echo v5 Apr 2, 2026
@giortzisg giortzisg changed the title feat!(echo): add support for Echo v5 feat!: add support for Echo v5 Apr 2, 2026
@giortzisg giortzisg merged commit 2cec51a into getsentry:master Apr 2, 2026
21 of 23 checks passed
@MartinodF
Copy link
Copy Markdown

What are the plans for cutting a release with this? We're eagerly awaiting a new version to be published and I wanted to avoid pinning a specific commit on the master branch :) Thanks!

@giortzisg
Copy link
Copy Markdown
Contributor

I want to also include one more thing for the release, but will happen this or the next week.

@giortzisg
Copy link
Copy Markdown
Contributor

@MartinodF just released https://github.com/getsentry/sentry-go/releases/tag/v0.45.0

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.

4 participants