Skip to content

Conversation

@renovate
Copy link
Contributor

@renovate renovate bot commented May 24, 2025

This PR contains the following updates:

Package Change Age Confidence
github.com/labstack/echo/v4 v4.13.3v4.15.0 age confidence

Release Notes

labstack/echo (github.com/labstack/echo/v4)

v4.15.0

Compare Source

Security

NB: If your application relies on cross-origin or same-site (same subdomain) requests do not blindly push this version to production

The CSRF middleware now supports the Sec-Fetch-Site header as a modern, defense-in-depth approach to CSRF
protection
, implementing the OWASP-recommended Fetch Metadata API alongside the traditional token-based mechanism.

How it works:

Modern browsers automatically send the Sec-Fetch-Site header with all requests, indicating the relationship
between the request origin and the target. The middleware uses this to make security decisions:

  • same-origin or none: Requests are allowed (exact origin match or direct user navigation)
  • same-site: Falls back to token validation (e.g., subdomain to main domain)
  • cross-site: Blocked by default with 403 error for unsafe methods (POST, PUT, DELETE, PATCH)

For browsers that don't send this header (older browsers), the middleware seamlessly falls back to
traditional token-based CSRF protection.

New Configuration Options:

  • TrustedOrigins []string: Allowlist specific origins for cross-site requests (useful for OAuth callbacks, webhooks)
  • AllowSecFetchSiteFunc func(echo.Context) (bool, error): Custom logic for same-site/cross-site request validation

Example:

e.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
    // Allow OAuth callbacks from trusted provider
    TrustedOrigins: []string{"https://oauth-provider.com"},

    // Custom validation for same-site requests
    AllowSecFetchSiteFunc: func(c echo.Context) (bool, error) {
        // Your custom authorization logic here
        return validateCustomAuth(c), nil
        // return true, err  // blocks request with error
        // return true, nil  // allows CSRF request through
        // return false, nil // falls back to legacy token logic
    },
}))

PR: #​2858

Type-Safe Generic Parameter Binding

  • Added generic functions for type-safe parameter extraction and context access by @​aldas in #​2856

    Echo now provides generic functions for extracting path, query, and form parameters with automatic type conversion,
    eliminating manual string parsing and type assertions.

    New Functions:

    • Path parameters: PathParam[T], PathParamOr[T]
    • Query parameters: QueryParam[T], QueryParamOr[T], QueryParams[T], QueryParamsOr[T]
    • Form values: FormParam[T], FormParamOr[T], FormParams[T], FormParamsOr[T]
    • Context store: ContextGet[T], ContextGetOr[T]

    Supported Types:
    Primitives (bool, string, int/uint variants, float32/float64), time.Duration, time.Time
    (with custom layouts and Unix timestamp support), and custom types implementing BindUnmarshaler,
    TextUnmarshaler, or JSONUnmarshaler.

    Example:

    // Before: Manual parsing
    idStr := c.Param("id")
    id, err := strconv.Atoi(idStr)
    
    // After: Type-safe with automatic parsing
    id, err := echo.PathParam[int](c, "id")
    
    // With default values
    page, err := echo.QueryParamOr[int](c, "page", 1)
    limit, err := echo.QueryParamOr[int](c, "limit", 20)
    
    // Type-safe context access (no more panics from type assertions)
    user, err := echo.ContextGet[*User](c, "user")

PR: #​2856

DEPRECATION NOTICE Timeout Middleware Deprecated - Use ContextTimeout Instead

The middleware.Timeout middleware has been deprecated due to fundamental architectural issues that cause
data races. Use middleware.ContextTimeout or middleware.ContextTimeoutWithConfig instead.

Why is this being deprecated?

The Timeout middleware manipulates response writers across goroutine boundaries, which causes data races that
cannot be reliably fixed without a complete architectural redesign. The middleware:

  • Swaps the response writer using http.TimeoutHandler
  • Must be the first middleware in the chain (fragile constraint)
  • Can cause races with other middleware (Logger, metrics, custom middleware)
  • Has been the source of multiple race condition fixes over the years

What should you use instead?

The ContextTimeout middleware (available since v4.12.0) provides timeout functionality using Go's standard
context mechanism. It is:

  • Race-free by design
  • Can be placed anywhere in the middleware chain
  • Simpler and more maintainable
  • Compatible with all other middleware

Migration Guide:

// Before (deprecated):
e.Use(middleware.Timeout())

// After (recommended):
e.Use(middleware.ContextTimeout(30 * time.Second))

Important Behavioral Differences:

  1. Handler cooperation required: With ContextTimeout, your handlers must check context.Done() for cooperative
    cancellation. The old Timeout middleware would send a 503 response regardless of handler cooperation, but had
    data race issues.

  2. Error handling: ContextTimeout returns errors through the standard error handling flow. Handlers that receive
    context.DeadlineExceeded should handle it appropriately:

e.GET("/long-task", func(c echo.Context) error {
    ctx := c.Request().Context()

    // Example: database query with context
    result, err := db.QueryContext(ctx, "SELECT * FROM large_table")
    if err != nil {
        if errors.Is(err, context.DeadlineExceeded) {
            // Handle timeout
            return echo.NewHTTPError(http.StatusServiceUnavailable, "Request timeout")
        }
        return err
    }

    return c.JSON(http.StatusOK, result)
})
  1. Background tasks: For long-running background tasks, use goroutines with context:
e.GET("/async-task", func(c echo.Context) error {
    ctx := c.Request().Context()

    resultCh := make(chan Result, 1)
    errCh := make(chan error, 1)

    go func() {
        result, err := performLongTask(ctx)
        if err != nil {
            errCh <- err
            return
        }
        resultCh <- result
    }()

    select {
    case result := <-resultCh:
        return c.JSON(http.StatusOK, result)
    case err := <-errCh:
        return err
    case <-ctx.Done():
        return echo.NewHTTPError(http.StatusServiceUnavailable, "Request timeout")
    }
})

Enhancements

v4.14.0

Compare Source

middleware.Logger has been deprecated. For request logging, use middleware.RequestLogger or
middleware.RequestLoggerWithConfig.

middleware.RequestLogger replaces middleware.Logger, offering comparable configuration while relying on the
Go standard library’s new slog logger.

The previous default output format was JSON. The new default follows the standard slog logger settings.
To continue emitting request logs in JSON, configure slog accordingly:

slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, nil)))
e.Use(middleware.RequestLogger())

Security

Enhancements

v4.13.4

Compare Source

Enhancements

Security


Configuration

📅 Schedule: Branch creation - Between 12:00 AM and 03:59 AM ( * 0-3 * * * ) in timezone America/Los_Angeles, Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate renovate bot enabled auto-merge (squash) May 24, 2025 10:13
@renovate renovate bot force-pushed the renovate/github.com-labstack-echo-v4-4.x branch from 112e77c to 4379a44 Compare June 10, 2025 23:11
@renovate renovate bot changed the title Update module github.com/labstack/echo/v4 to v4.13.4 Update module github.com/labstack/echo/v4 to v4.13.4 - autoclosed Aug 1, 2025
@renovate renovate bot closed this Aug 1, 2025
auto-merge was automatically disabled August 1, 2025 19:42

Pull request was closed

@renovate renovate bot deleted the renovate/github.com-labstack-echo-v4-4.x branch August 1, 2025 19:42
@renovate renovate bot changed the title Update module github.com/labstack/echo/v4 to v4.13.4 - autoclosed Update module github.com/labstack/echo/v4 to v4.13.4 Aug 3, 2025
@renovate renovate bot reopened this Aug 3, 2025
@renovate renovate bot force-pushed the renovate/github.com-labstack-echo-v4-4.x branch from ba9e533 to 4379a44 Compare August 3, 2025 09:15
@renovate renovate bot enabled auto-merge (squash) August 3, 2025 13:58
@renovate renovate bot force-pushed the renovate/github.com-labstack-echo-v4-4.x branch 2 times, most recently from be54227 to 7135713 Compare September 17, 2025 21:35
@renovate renovate bot changed the title Update module github.com/labstack/echo/v4 to v4.13.4 Update module github.com/labstack/echo/v4 to v4.13.4 - autoclosed Nov 20, 2025
@renovate renovate bot closed this Nov 20, 2025
auto-merge was automatically disabled November 20, 2025 13:09

Pull request was closed

@renovate renovate bot changed the title Update module github.com/labstack/echo/v4 to v4.13.4 - autoclosed Update module github.com/labstack/echo/v4 to v4.13.4 Nov 21, 2025
@renovate renovate bot reopened this Nov 21, 2025
@renovate renovate bot force-pushed the renovate/github.com-labstack-echo-v4-4.x branch 2 times, most recently from 7135713 to d8e80d3 Compare November 21, 2025 11:01
@renovate renovate bot enabled auto-merge (squash) November 21, 2025 13:47
@renovate renovate bot force-pushed the renovate/github.com-labstack-echo-v4-4.x branch from d8e80d3 to ead25ca Compare December 12, 2025 03:49
@renovate renovate bot changed the title Update module github.com/labstack/echo/v4 to v4.13.4 Update module github.com/labstack/echo/v4 to v4.14.0 Dec 12, 2025
| datasource | package                     | from    | to      |
| ---------- | --------------------------- | ------- | ------- |
| go         | github.com/labstack/echo/v4 | v4.13.3 | v4.15.0 |


Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@renovate renovate bot force-pushed the renovate/github.com-labstack-echo-v4-4.x branch from ead25ca to 616593e Compare January 1, 2026 12:50
@renovate renovate bot changed the title Update module github.com/labstack/echo/v4 to v4.14.0 Update module github.com/labstack/echo/v4 to v4.15.0 Jan 1, 2026
@renovate
Copy link
Contributor Author

renovate bot commented Jan 1, 2026

ℹ️ Artifact update notice

File name: examples/go.mod

In order to perform the update(s) described in the table above, Renovate ran the go get command, which resulted in the following additional change(s):

  • 5 additional dependencies were updated
  • The go directive was updated for compatibility reasons

Details:

Package Change
go 1.22.11 -> 1.24.0
github.com/mattn/go-colorable v0.1.13 -> v0.1.14
golang.org/x/crypto v0.31.0 -> v0.46.0
golang.org/x/net v0.33.0 -> v0.48.0
golang.org/x/sys v0.28.0 -> v0.39.0
golang.org/x/text v0.21.0 -> v0.32.0
File name: go.mod

In order to perform the update(s) described in the table above, Renovate ran the go get command, which resulted in the following additional change(s):

  • 5 additional dependencies were updated
  • The go directive was updated for compatibility reasons

Details:

Package Change
go 1.22.11 -> 1.24.0
github.com/mattn/go-colorable v0.1.13 -> v0.1.14
golang.org/x/crypto v0.31.0 -> v0.46.0
golang.org/x/net v0.33.0 -> v0.48.0
golang.org/x/sys v0.28.0 -> v0.39.0
golang.org/x/text v0.21.0 -> v0.32.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant