Skip to content

feat(echo): add support for Echo v5#1183

Open
Scorfly wants to merge 1 commit intogetsentry:masterfrom
Scorfly:bump-echo-middleware
Open

feat(echo): add support for Echo v5#1183
Scorfly wants to merge 1 commit intogetsentry:masterfrom
Scorfly:bump-echo-middleware

Conversation

@Scorfly
Copy link

@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

github-actions bot commented Jan 24, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

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


New Features ✨

  • (echo) Add support for Echo v5 by Scorfly in #1183
  • Add support for homogenous arrays by giortzisg in #1203
  • Add support for client reports by giortzisg in #1192
  • Add org id propagation in sentry_baggage by giortzisg in #1210
  • Add OrgID and StrictTraceContinuation client options. by giortzisg in #1210
  • Add the option to set attributes on the scope by giortzisg in #1208

Bug Fixes 🐛

  • (serialization) Pre-serialize mutable event fields to prevent race panics by giortzisg in #1214
  • Use HEROKU_BUILD_COMMIT with HEROKU_SLUG_COMMIT as fallback by ericapisani in #1220

Internal Changes 🔧

Ai

  • Add AGENTS.md and testing guidelines by giortzisg in #1216
  • Add dotagents configuration by giortzisg in #1211

Deps

  • Bump getsentry/craft from 2.20.1 to 2.23.1 by dependabot in #1213
  • Bump github.com/gofiber/fiber/v2 from 2.52.11 to 2.52.12 in /fiber by dependabot in #1209

Other

  • Handle independent go module versions for integrations by giortzisg in #1217

🤖 This preview updates automatically when you update the PR.

@giortzisg
Copy link
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

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

@giortzisg
Copy link
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
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
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

codecov bot commented Mar 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.29%. Comparing base (1ce3436) to head (535b494).
⚠️ Report is 51 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1183      +/-   ##
==========================================
- Coverage   86.04%   82.29%   -3.75%     
==========================================
  Files          62       75      +13     
  Lines        6090     7265    +1175     
==========================================
+ Hits         5240     5979     +739     
- Misses        635     1017     +382     
- Partials      215      269      +54     

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

@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
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