Skip to content

Modern Docker Management, Designed for Everyone

refactor: migrate from echo/v4 to echo/v5 (#3365)

Kyle Mendell73d13dc7391c
diff --git a/.depot/workflows/ci.yml b/.depot/workflows/ci.yml
index 454182345..c939b0739 100644
--- a/.depot/workflows/ci.yml
+++ b/.depot/workflows/ci.yml
@@ -122,8 +122,6 @@ jobs:
type-check:
name: Type Check
runs-on: depot-ubuntu-latest
- env:
- PNPM_STORE_DIR: /tmp/arcane-ci-cache/type-check/pnpm-store
steps:
- name: Checkout code
uses: actions/checkout@v7
@@ -135,16 +133,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: 26
-
- - name: Mount pnpm store
- uses: depot/cache-mount@v1
- with:
- path: /tmp/arcane-ci-cache
- name: getarcaneapp-arcane-main-ci-type-check
- write-lock: /tmp/arcane-ci-cache
-
- - name: Configure pnpm store
- run: pnpm config set store-dir "$PNPM_STORE_DIR"
+ cache: pnpm
- name: Setup Just
uses: extractions/setup-just@v4
@@ -164,9 +153,6 @@ jobs:
e2e-tests:
name: E2E Tests (${{ matrix.database.name }})
runs-on: depot-ubuntu-24.04-4
- env:
- PNPM_STORE_DIR: /tmp/arcane-ci-cache/e2e/${{ matrix.database.name }}/pnpm-store
- PLAYWRIGHT_CACHE_ROOT: /tmp/arcane-ci-cache/e2e/${{ matrix.database.name }}/playwright
permissions:
contents: read
actions: write
@@ -200,18 +186,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: 26
-
- - name: Mount test dependency cache
- uses: depot/cache-mount@v1
- with:
- path: /tmp/arcane-ci-cache
- name: getarcaneapp-arcane-main-ci-e2e-${{ matrix.database.name }}
- write-lock: /tmp/arcane-ci-cache
-
- - name: Configure test dependency cache
- run: |
- pnpm config set store-dir "$PNPM_STORE_DIR"
- echo "PLAYWRIGHT_BROWSERS_PATH=$PLAYWRIGHT_CACHE_ROOT/${{ hashFiles('pnpm-lock.yaml', 'tests/package.json') }}" >> "$GITHUB_ENV"
+ cache: pnpm
- name: Set up Depot CLI
uses: depot/setup-action@v1
@@ -219,6 +194,15 @@ jobs:
- name: Setup depot buildx driver
run: depot configure-docker
+ - name: Cache Playwright Browsers
+ uses: actions/cache@v6
+ id: playwright-cache
+ with:
+ path: ~/.cache/ms-playwright
+ key: ${{ runner.os }}-playwright-${{ hashFiles('tests/pnpm-lock.yaml', 'tests/package.json') }}
+ restore-keys: |
+ ${{ runner.os }}-playwright-
+
- name: Pull and save test images
run: |
docker pull public.ecr.aws/nginx/nginx:stable-alpine
@@ -253,8 +237,6 @@ jobs:
cli-e2e-tests:
name: CLI E2E Tests (proxy)
runs-on: depot-ubuntu-24.04-4
- env:
- PNPM_STORE_DIR: /tmp/arcane-ci-cache/cli-e2e/pnpm-store
permissions:
contents: read
actions: write
@@ -272,6 +254,7 @@ jobs:
uses: actions/setup-node@v6
with:
node-version: 26
+ cache: pnpm
- name: Setup Go
uses: actions/setup-go@v7
@@ -280,16 +263,6 @@ jobs:
cache: true
cache-dependency-path: cli/go.sum
- - name: Mount dependency cache
- uses: depot/cache-mount@v1
- with:
- path: /tmp/arcane-ci-cache
- name: getarcaneapp-arcane-main-ci-cli-e2e
- write-lock: /tmp/arcane-ci-cache
-
- - name: Configure pnpm store
- run: pnpm config set store-dir "$PNPM_STORE_DIR"
-
- name: Set up Depot CLI
uses: depot/setup-action@v1
diff --git a/backend/api/api.go b/backend/api/api.go
index f731e01a8..45c157ec0 100644
--- a/backend/api/api.go
+++ b/backend/api/api.go
@@ -15,7 +15,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/api/middleware"
"github.com/getarcaneapp/arcane/backend/v2/internal/config"
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"go.uber.org/fx"
)
@@ -305,7 +305,7 @@ const scalarDocsHTML = `<!doctype html>
// registerScalarDocs adds the Scalar API documentation endpoint.
func registerScalarDocs(apiGroup *echo.Group) {
- apiGroup.GET("/docs", func(c echo.Context) error {
+ apiGroup.GET("/docs", func(c *echo.Context) error {
return c.HTML(http.StatusOK, scalarDocsHTML)
})
}
@@ -314,8 +314,6 @@ func registerScalarDocs(apiGroup *echo.Group) {
// No services are required - this is purely for schema generation.
func SetupAPIForSpec() huma.API {
e := echo.New()
- e.HideBanner = true
- e.HidePort = true
apiGroup := e.Group("/api")
humaConfig := huma.DefaultConfig("Arcane API", config.Version)
diff --git a/backend/api/api_test.go b/backend/api/api_test.go
index 024217a89..0a6cea428 100644
--- a/backend/api/api_test.go
+++ b/backend/api/api_test.go
@@ -19,7 +19,7 @@ import (
networktypes "github.com/getarcaneapp/arcane/types/v2/network"
projecttypes "github.com/getarcaneapp/arcane/types/v2/project"
volumetypes "github.com/getarcaneapp/arcane/types/v2/volume"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
dockercontainer "github.com/moby/moby/api/types/container"
dockernetwork "github.com/moby/moby/api/types/network"
"github.com/stretchr/testify/require"
diff --git a/backend/api/buildables.go b/backend/api/buildables.go
index 773a4b904..e93083970 100644
--- a/backend/api/buildables.go
+++ b/backend/api/buildables.go
@@ -15,7 +15,7 @@ import (
"github.com/getarcaneapp/arcane/types/v2/auth"
"github.com/getarcaneapp/arcane/types/v2/base"
"github.com/getarcaneapp/arcane/types/v2/user"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
// SetupBuildablesRoutes registers buildable feature routes based on EnabledFeatures.
@@ -28,7 +28,7 @@ func SetupBuildablesRoutes(apiGroup *echo.Group, authService *services.AuthServi
func registerAutoLoginRoutes(apiGroup *echo.Group, authService *services.AuthService) {
authGroup := apiGroup.Group("/auth")
- authGroup.GET("/auto-login-config", func(c echo.Context) error {
+ authGroup.GET("/auto-login-config", func(c *echo.Context) error {
if authService == nil {
return c.JSON(http.StatusInternalServerError, base.ErrorResponse{Error: "service not available"})
}
@@ -44,7 +44,7 @@ func registerAutoLoginRoutes(apiGroup *echo.Group, authService *services.AuthSer
})
})
- authGroup.POST("/auto-login", func(c echo.Context) error {
+ authGroup.POST("/auto-login", func(c *echo.Context) error {
if authService == nil {
return c.JSON(http.StatusInternalServerError, base.ErrorResponse{Error: "service not available"})
}
diff --git a/backend/api/handlers/events.go b/backend/api/handlers/events.go
index 2a4ca751a..7a471b86e 100644
--- a/backend/api/handlers/events.go
+++ b/backend/api/handlers/events.go
@@ -16,7 +16,7 @@ import (
pkgutils "github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
"github.com/getarcaneapp/arcane/types/v2/base"
"github.com/getarcaneapp/arcane/types/v2/event"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
// EventHandler handles event management endpoints.
@@ -79,7 +79,7 @@ type DeleteEventOutput struct {
// direct agents when no edge tunnel is active. This route is not part of the
// Huma/OpenAPI surface and authenticates only with the configured agent token.
func RegisterAgentEventIngestion(g *echo.Group, eventService *services.EventService, cfg *config.Config) {
- g.POST("/events", func(c echo.Context) error {
+ g.POST("/events", func(c *echo.Context) error {
if eventService == nil {
return c.JSON(http.StatusInternalServerError, base.ApiResponse[base.MessageResponse]{
Success: false,
diff --git a/backend/api/handlers/events_test.go b/backend/api/handlers/events_test.go
index 4bc0649fb..00741ff8e 100644
--- a/backend/api/handlers/events_test.go
+++ b/backend/api/handlers/events_test.go
@@ -14,7 +14,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
pkgutils "github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
sqlite "github.com/libtnb/sqlite"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
diff --git a/backend/api/handlers/federated.go b/backend/api/handlers/federated.go
index ae6e404b5..625b8d513 100644
--- a/backend/api/handlers/federated.go
+++ b/backend/api/handlers/federated.go
@@ -12,7 +12,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
"github.com/getarcaneapp/arcane/types/v2/base"
federatedtypes "github.com/getarcaneapp/arcane/types/v2/federated"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
// FederatedCredentialHandler provides Huma-based federated credential
@@ -75,7 +75,7 @@ type DeleteFederatedCredentialOutput struct {
// endpoint. It intentionally uses Echo because the standard requires form
// encoding while the rest of Arcane's Huma API is JSON-first.
func RegisterFederatedTokenExchange(g *echo.Group, federatedCredentialService *services.FederatedCredentialService) {
- g.POST("/auth/federated/token", func(c echo.Context) error {
+ g.POST("/auth/federated/token", func(c *echo.Context) error {
if federatedCredentialService == nil {
return c.JSON(http.StatusInternalServerError, federatedTokenExchangeError{
Error: "server_error",
@@ -249,7 +249,7 @@ func (h *FederatedCredentialHandler) DeleteFederatedCredential(ctx context.Conte
}, nil
}
-func writeFederatedTokenExchangeErrorInternal(c echo.Context, err error) error {
+func writeFederatedTokenExchangeErrorInternal(c *echo.Context, err error) error {
var code string
description := "token exchange rejected"
diff --git a/backend/api/handlers/git_repositories_test.go b/backend/api/handlers/git_repositories_test.go
index d5ce48363..f858eb9dc 100644
--- a/backend/api/handlers/git_repositories_test.go
+++ b/backend/api/handlers/git_repositories_test.go
@@ -8,7 +8,7 @@ import (
"github.com/danielgtaylor/huma/v2"
"github.com/danielgtaylor/huma/v2/adapters/humaecho"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/require"
humamw "github.com/getarcaneapp/arcane/backend/v2/api/middleware"
diff --git a/backend/api/handlers/notifications_test.go b/backend/api/handlers/notifications_test.go
index a8afcb2f0..96a190243 100644
--- a/backend/api/handlers/notifications_test.go
+++ b/backend/api/handlers/notifications_test.go
@@ -21,7 +21,7 @@ import (
"github.com/getarcaneapp/arcane/types/v2/base"
"github.com/getarcaneapp/arcane/types/v2/imageupdate"
notificationdto "github.com/getarcaneapp/arcane/types/v2/notification"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
sqlite "github.com/libtnb/sqlite"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
diff --git a/backend/api/handlers/permission_gating_test.go b/backend/api/handlers/permission_gating_test.go
index 1d703058c..92e6ebd50 100644
--- a/backend/api/handlers/permission_gating_test.go
+++ b/backend/api/handlers/permission_gating_test.go
@@ -8,7 +8,7 @@ import (
"github.com/danielgtaylor/huma/v2/adapters/humaecho"
humamw "github.com/getarcaneapp/arcane/backend/v2/api/middleware"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
func newPermissionGatingRouterInternal(t *testing.T, ps *authz.PermissionSet) (*echo.Echo, huma.API) {
diff --git a/backend/api/handlers/templates_test.go b/backend/api/handlers/templates_test.go
index 35e5b023e..fdd686ba0 100644
--- a/backend/api/handlers/templates_test.go
+++ b/backend/api/handlers/templates_test.go
@@ -19,7 +19,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
"github.com/golang-jwt/jwt/v5"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
sqlite "github.com/libtnb/sqlite"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
diff --git a/backend/api/handlers/variables_test.go b/backend/api/handlers/variables_test.go
index a5462ff6b..350fc6099 100644
--- a/backend/api/handlers/variables_test.go
+++ b/backend/api/handlers/variables_test.go
@@ -13,7 +13,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/models"
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
sqlite "github.com/libtnb/sqlite"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
diff --git a/backend/api/json_serializer.go b/backend/api/json_serializer.go
index 0e3dc41f0..c34339156 100644
--- a/backend/api/json_serializer.go
+++ b/backend/api/json_serializer.go
@@ -9,7 +9,7 @@ import (
"emperror.dev/errors"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
type jsonV2Serializer struct{}
@@ -17,7 +17,7 @@ type jsonV2Serializer struct{}
// Preserve the established numeric wire format for duration fields in third-party API types.
var jsonV2APIOptions = jsonv1.FormatDurationAsNano(true)
-func (jsonV2Serializer) Serialize(c echo.Context, value any, indent string) error {
+func (jsonV2Serializer) Serialize(c *echo.Context, value any, indent string) error {
if indent != "" {
return json.MarshalWrite(c.Response(), value, jsonV2APIOptions, jsontext.WithIndent(indent))
}
@@ -25,7 +25,7 @@ func (jsonV2Serializer) Serialize(c echo.Context, value any, indent string) erro
return json.MarshalWrite(c.Response(), value, jsonV2APIOptions)
}
-func (jsonV2Serializer) Deserialize(c echo.Context, value any) error {
+func (jsonV2Serializer) Deserialize(c *echo.Context, value any) error {
err := json.UnmarshalRead(c.Request().Body, value, jsonV2APIOptions)
if err == nil {
return nil
@@ -42,7 +42,7 @@ func (jsonV2Serializer) Deserialize(c echo.Context, value any) error {
semanticErr.JSONPointer,
semanticErr.ByteOffset,
),
- ).SetInternal(err)
+ ).Wrap(err)
}
var syntacticErr *jsontext.SyntacticError
@@ -50,7 +50,7 @@ func (jsonV2Serializer) Deserialize(c echo.Context, value any) error {
return echo.NewHTTPError(
http.StatusBadRequest,
fmt.Sprintf("Syntax error: offset=%v, error=%v", syntacticErr.ByteOffset, syntacticErr.Error()),
- ).SetInternal(err)
+ ).Wrap(err)
}
return err
diff --git a/backend/api/json_serializer_test.go b/backend/api/json_serializer_test.go
index ebaf1024f..bfd2a824e 100644
--- a/backend/api/json_serializer_test.go
+++ b/backend/api/json_serializer_test.go
@@ -8,7 +8,7 @@ import (
"testing"
"time"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
func TestJSONV2SerializerUsesV2ResponseSemantics(t *testing.T) {
@@ -84,8 +84,8 @@ func TestJSONV2SerializerUsesStrictV2Decoding(t *testing.T) {
if !errors.As(err, &httpErr) {
t.Fatalf("deserialize error = %T %v, want *echo.HTTPError", err, err)
}
- if httpErr.Code != http.StatusBadRequest {
- t.Fatalf("HTTP status = %d, want %d", httpErr.Code, http.StatusBadRequest)
+ if httpErr.StatusCode() != http.StatusBadRequest {
+ t.Fatalf("HTTP status = %d, want %d", httpErr.StatusCode(), http.StatusBadRequest)
}
})
}
diff --git a/backend/api/middleware/auth_test.go b/backend/api/middleware/auth_test.go
index 941e3f0ef..83dbf1b11 100644
--- a/backend/api/middleware/auth_test.go
+++ b/backend/api/middleware/auth_test.go
@@ -16,7 +16,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
"github.com/getarcaneapp/arcane/types/v2/auth"
"github.com/golang-jwt/jwt/v5"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
sqlite "github.com/libtnb/sqlite"
"github.com/stretchr/testify/require"
"gorm.io/gorm"
diff --git a/backend/api/middleware/role_test.go b/backend/api/middleware/role_test.go
index f56342489..2fb0d7dae 100644
--- a/backend/api/middleware/role_test.go
+++ b/backend/api/middleware/role_test.go
@@ -8,7 +8,7 @@ import (
"github.com/danielgtaylor/huma/v2"
"github.com/danielgtaylor/huma/v2/adapters/humaecho"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/require"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
diff --git a/backend/api/playwright.go b/backend/api/playwright.go
index 45d4156aa..bb89edf44 100644
--- a/backend/api/playwright.go
+++ b/backend/api/playwright.go
@@ -6,7 +6,7 @@ import (
"net/http"
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
type PlaywrightHandler struct {
@@ -39,7 +39,7 @@ type CreateTestFederatedCredentialRequest struct {
TokenTTLSeconds int `json:"tokenTtlSeconds"`
}
-func (ph *PlaywrightHandler) CreateTestApiKeysHandler(c echo.Context) error {
+func (ph *PlaywrightHandler) CreateTestApiKeysHandler(c *echo.Context) error {
var req CreateTestApiKeysRequest
if err := c.Bind(&req); err != nil {
req.Count = 2
@@ -57,7 +57,7 @@ func (ph *PlaywrightHandler) CreateTestApiKeysHandler(c echo.Context) error {
return c.JSON(http.StatusCreated, map[string]any{"apiKeys": apiKeys})
}
-func (ph *PlaywrightHandler) DeleteTestApiKeysHandler(c echo.Context) error {
+func (ph *PlaywrightHandler) DeleteTestApiKeysHandler(c *echo.Context) error {
if err := ph.PlaywrightService.DeleteAllTestApiKeys(c.Request().Context()); err != nil {
return c.JSON(http.StatusInternalServerError, map[string]any{"error": err.Error()})
}
@@ -65,7 +65,7 @@ func (ph *PlaywrightHandler) DeleteTestApiKeysHandler(c echo.Context) error {
return c.NoContent(http.StatusNoContent)
}
-func (ph *PlaywrightHandler) CreateTestFederatedCredentialHandler(c echo.Context) error {
+func (ph *PlaywrightHandler) CreateTestFederatedCredentialHandler(c *echo.Context) error {
var req CreateTestFederatedCredentialRequest
if err := c.Bind(&req); err != nil {
return c.JSON(http.StatusBadRequest, map[string]any{"error": "invalid request body"})
diff --git a/backend/api/webhooks_trigger.go b/backend/api/webhooks_trigger.go
index 22efee02c..24cddab2a 100644
--- a/backend/api/webhooks_trigger.go
+++ b/backend/api/webhooks_trigger.go
@@ -8,14 +8,14 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/api/handlers"
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
// RegisterWebhookTrigger registers the public (unauthenticated) trigger endpoint.
// The token in the URL is the sole authentication mechanism.
// Rate-limited via PerIPRateLimitForPaths in router_bootstrap.go.
func RegisterWebhookTrigger(g *echo.Group, webhookService *services.WebhookService, appCtx handlers.ActivityAppContext) {
- g.POST("/webhooks/trigger/:token", func(c echo.Context) error {
+ g.POST("/webhooks/trigger/:token", func(c *echo.Context) error {
if webhookService == nil {
return c.JSON(http.StatusInternalServerError, map[string]any{"success": false, "error": "service not available"})
}
diff --git a/backend/api/ws/diagnostics.go b/backend/api/ws/diagnostics.go
index 4d9cef032..8a382a9c8 100644
--- a/backend/api/ws/diagnostics.go
+++ b/backend/api/ws/diagnostics.go
@@ -12,7 +12,7 @@ import (
wshub "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/ws"
systemtypes "github.com/getarcaneapp/arcane/types/v2/system"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"go.getarcane.app/streams/logs"
)
@@ -59,8 +59,8 @@ func (h *WebSocketHandler) registerDiagnosticsRoutesInternal(group *echo.Group,
// DiagnosticsStream pushes a fresh diagnostics snapshot on connect and then every
// diagnosticsStreamInterval until the client disconnects.
-func (h *WebSocketHandler) DiagnosticsStream(c echo.Context) error {
- conn, err := h.wsUpgrader.Upgrade(c.Response().Writer, c.Request(), nil)
+func (h *WebSocketHandler) DiagnosticsStream(c *echo.Context) error {
+ conn, err := h.wsUpgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
return nil
}
@@ -93,8 +93,8 @@ func (h *WebSocketHandler) DiagnosticsStream(c echo.Context) error {
}
// ServerLogsStream replays the recent backend log backlog then streams new entries live.
-func (h *WebSocketHandler) ServerLogsStream(c echo.Context) error {
- conn, err := h.wsUpgrader.Upgrade(c.Response().Writer, c.Request(), nil)
+func (h *WebSocketHandler) ServerLogsStream(c *echo.Context) error {
+ conn, err := h.wsUpgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
return nil
}
diff --git a/backend/api/ws/handler.go b/backend/api/ws/handler.go
index c244dac31..92888eb7f 100644
--- a/backend/api/ws/handler.go
+++ b/backend/api/ws/handler.go
@@ -16,7 +16,7 @@ import (
"emperror.dev/errors"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/samber/hot"
"github.com/shirou/gopsutil/v4/cpu"
"github.com/shirou/gopsutil/v4/disk"
@@ -97,7 +97,7 @@ type wsLogStream struct {
seq atomic.Uint64
}
-func getContextUserIDInternal(c echo.Context) string {
+func getContextUserIDInternal(c *echo.Context) string {
if val := c.Get("userID"); val != nil {
if userID, ok := val.(string); ok {
return userID
@@ -106,7 +106,7 @@ func getContextUserIDInternal(c echo.Context) string {
return ""
}
-func buildWSConnectionInfoInternal(c echo.Context, kind, resourceID string) systemtypes.WebSocketConnectionInfo {
+func buildWSConnectionInfoInternal(c *echo.Context, kind, resourceID string) systemtypes.WebSocketConnectionInfo {
return systemtypes.WebSocketConnectionInfo{
Kind: kind,
EnvID: c.Param("id"),
@@ -260,7 +260,7 @@ type logStreamParams struct {
batched bool
}
-func parseLogStreamParamsInternal(c echo.Context) logStreamParams {
+func parseLogStreamParamsInternal(c *echo.Context) logStreamParams {
req := c.Request()
tail, _ := httputil.GetQueryParam(req, "tail", false)
if tail == "" {
@@ -281,7 +281,7 @@ func parseLogStreamParamsInternal(c echo.Context) logStreamParams {
}
}
-func queryParamWithDefaultInternal(c echo.Context, key, def string) string {
+func queryParamWithDefaultInternal(c *echo.Context, key, def string) string {
if v := c.QueryParam(key); v != "" {
return v
}
@@ -293,12 +293,12 @@ func queryParamWithDefaultInternal(c echo.Context, key, def string) string {
// and serves the client. The caller-supplied hubBuilder constructs the underlying *wsLogStream
// when no hub already exists for streamKey.
func (h *WebSocketHandler) serveLogStreamInternal(
- c echo.Context,
+ c *echo.Context,
kind, resourceID string,
params logStreamParams,
hubBuilder func(streamKey string, onEmpty func(*wsLogStream)) *wsLogStream,
) {
- conn, err := h.wsUpgrader.Upgrade(c.Response().Writer, c.Request(), nil)
+ conn, err := h.wsUpgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
return
}
@@ -358,7 +358,7 @@ func broadcastLogStreamErrorInternal(resourceLabel, errorPrefix string, resource
// @Param format query string false "Output format (text or json)" default(text)
// @Param batched query bool false "Batch log messages" default(false)
// @Router /api/environments/{id}/ws/projects/{projectId}/logs [get]
-func (h *WebSocketHandler) ProjectLogs(c echo.Context) error {
+func (h *WebSocketHandler) ProjectLogs(c *echo.Context) error {
projectID := c.Param("projectId")
if strings.TrimSpace(projectID) == "" {
return c.JSON(http.StatusBadRequest, map[string]any{"success": false, "error": "Project ID is required"})
@@ -566,7 +566,7 @@ func mapLogLinesInternal[T any](ctx context.Context, lines <-chan string, transf
// @Param format query string false "Output format (text or json)" default(text)
// @Param batched query bool false "Batch log messages" default(false)
// @Router /api/environments/{id}/ws/containers/{containerId}/logs [get]
-func (h *WebSocketHandler) ContainerLogs(c echo.Context) error {
+func (h *WebSocketHandler) ContainerLogs(c *echo.Context) error {
containerID := c.Param("containerId")
if strings.TrimSpace(containerID) == "" {
return c.JSON(http.StatusBadRequest, map[string]any{"success": false, "error": "Container ID is required"})
@@ -606,7 +606,7 @@ func (h *WebSocketHandler) ContainerLogs(c echo.Context) error {
// @Param format query string false "Output format (text or json)" default(text)
// @Param batched query bool false "Batch log messages" default(false)
// @Router /api/environments/{id}/ws/swarm/services/{serviceId}/logs [get]
-func (h *WebSocketHandler) ServiceLogs(c echo.Context) error {
+func (h *WebSocketHandler) ServiceLogs(c *echo.Context) error {
serviceID := c.Param("serviceId")
if strings.TrimSpace(serviceID) == "" {
return c.JSON(http.StatusBadRequest, map[string]any{"success": false, "error": "Service ID is required"})
@@ -636,13 +636,13 @@ func (h *WebSocketHandler) ServiceLogs(c echo.Context) error {
// @Param id path string true "Environment ID"
// @Param containerId path string true "Container ID"
// @Router /api/environments/{id}/ws/containers/{containerId}/stats [get]
-func (h *WebSocketHandler) ContainerStats(c echo.Context) error {
+func (h *WebSocketHandler) ContainerStats(c *echo.Context) error {
containerID := c.Param("containerId")
if strings.TrimSpace(containerID) == "" {
return c.JSON(http.StatusBadRequest, map[string]any{"success": false, "error": "Container ID is required"})
}
- conn, err := h.wsUpgrader.Upgrade(c.Response().Writer, c.Request(), nil)
+ conn, err := h.wsUpgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
slog.DebugContext(c.Request().Context(), "Failed to upgrade WebSocket for container stats", "containerID", containerID, "error", err)
return nil
@@ -751,7 +751,7 @@ func (h *WebSocketHandler) runContainerStatsHubInternal(containerID string, hub
// @Param containerId path string true "Container ID"
// @Param shell query string false "Shell to execute" default(/bin/sh)
// @Router /api/environments/{id}/ws/containers/{containerId}/terminal [get]
-func (h *WebSocketHandler) ContainerExec(c echo.Context) error {
+func (h *WebSocketHandler) ContainerExec(c *echo.Context) error {
containerID := c.Param("containerId")
if strings.TrimSpace(containerID) == "" {
return c.JSON(http.StatusBadRequest, map[string]any{"success": false, "error": "Container ID is required"})
@@ -759,7 +759,7 @@ func (h *WebSocketHandler) ContainerExec(c echo.Context) error {
shell := queryParamWithDefaultInternal(c, "shell", "/bin/sh")
- conn, err := h.wsUpgrader.Upgrade(c.Response().Writer, c.Request(), nil)
+ conn, err := h.wsUpgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
return nil
}
@@ -1243,7 +1243,7 @@ func (h *WebSocketHandler) getCachedCgroupLimitsInternal() *cgroup.Limits {
// @Tags WebSocket
// @Param id path string true "Environment ID"
// @Router /api/environments/{id}/ws/system/stats [get]
-func (h *WebSocketHandler) SystemStats(c echo.Context) error {
+func (h *WebSocketHandler) SystemStats(c *echo.Context) error {
clientIP := c.RealIP()
count, allowed := h.checkRateLimitInternal(clientIP)
@@ -1255,7 +1255,7 @@ func (h *WebSocketHandler) SystemStats(c echo.Context) error {
}
defer h.releaseRateLimitInternal(clientIP, count)
- conn, err := h.wsUpgrader.Upgrade(c.Response().Writer, c.Request(), nil)
+ conn, err := h.wsUpgrader.Upgrade(c.Response(), c.Request(), nil)
if err != nil {
return nil
}
diff --git a/backend/api/ws/handler_test.go b/backend/api/ws/handler_test.go
index ad46c1a9a..5e5feb080 100644
--- a/backend/api/ws/handler_test.go
+++ b/backend/api/ws/handler_test.go
@@ -13,7 +13,7 @@ import (
"time"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/require"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/system"
diff --git a/backend/api/ws/proxy_permissions.go b/backend/api/ws/proxy_permissions.go
index 22b5ad8a8..a6c07589d 100644
--- a/backend/api/ws/proxy_permissions.go
+++ b/backend/api/ws/proxy_permissions.go
@@ -3,7 +3,7 @@ package ws
import (
"net/http"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
)
diff --git a/backend/frontend/excluded.go b/backend/frontend/excluded.go
index 85644ca53..1653a0b85 100644
--- a/backend/frontend/excluded.go
+++ b/backend/frontend/excluded.go
@@ -2,7 +2,7 @@
package frontend
-import "github.com/labstack/echo/v4"
+import "github.com/labstack/echo/v5"
func RegisterFrontend(e *echo.Echo) error {
_ = e
diff --git a/backend/frontend/frontend.go b/backend/frontend/frontend.go
index e4d7a9f2b..e8763bb84 100644
--- a/backend/frontend/frontend.go
+++ b/backend/frontend/frontend.go
@@ -13,7 +13,7 @@ import (
"emperror.dev/errors"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
//go:embed all:dist
@@ -21,9 +21,11 @@ var frontendFS embed.FS
const indexHtmlFileConstant = "index.html"
-// RegisterFrontend mounts the embedded SPA on the Echo instance and configures
-// a custom HTTP error handler that intercepts 404s to serve the SPA index
-// (preserving SvelteKit client-side routing) while keeping /api/* 404s as JSON.
+// RegisterFrontend mounts the embedded SPA as the Echo not-found fallback:
+// any path no API/WS route matched serves a real file when it exists and
+// falls back to index.html otherwise (preserving SvelteKit client-side
+// routing). Unknown /api paths are handled by the API group's own
+// RouteNotFound handler and never reach this route.
func RegisterFrontend(e *echo.Echo) error {
distFS, err := fs.Sub(frontendFS, "dist")
if err != nil {
@@ -33,27 +35,9 @@ func RegisterFrontend(e *echo.Echo) error {
cacheMaxAge := time.Hour * 24
fileServer := NewFileServerWithCaching(http.FS(distFS), int(cacheMaxAge.Seconds()))
- defaultErrorHandler := e.HTTPErrorHandler
- e.HTTPErrorHandler = func(handlerErr error, c echo.Context) {
- var he *echo.HTTPError
- isNotFound := errors.As(handlerErr, &he) && he.Code == http.StatusNotFound
- if !isNotFound {
- defaultErrorHandler(handlerErr, c)
- return
- }
-
+ e.RouteNotFound("/*", func(c *echo.Context) error {
req := c.Request()
- path := req.URL.Path
-
- if strings.HasPrefix(path, "/api/") {
- _ = c.JSON(http.StatusNotFound, map[string]any{
- "success": false,
- "error": "API endpoint not found: " + path,
- })
- return
- }
-
- requestedPath := strings.TrimPrefix(path, "/")
+ requestedPath := strings.TrimPrefix(req.URL.Path, "/")
if requestedPath == "" {
requestedPath = indexHtmlFileConstant
}
@@ -62,8 +46,9 @@ func RegisterFrontend(e *echo.Echo) error {
req.URL.Path = "/"
}
- fileServer.ServeHTTP(c.Response().Writer, req)
- }
+ fileServer.ServeHTTP(c.Response(), req)
+ return nil
+ })
return nil
}
diff --git a/backend/frontend/frontend_test.go b/backend/frontend/frontend_test.go
new file mode 100644
index 000000000..dfc644867
--- /dev/null
+++ b/backend/frontend/frontend_test.go
@@ -0,0 +1,38 @@
+//go:build !exclude_frontend
+
+package frontend
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "strings"
+ "testing"
+
+ "github.com/labstack/echo/v5"
+ "github.com/stretchr/testify/require"
+)
+
+// TestRegisterFrontend_ServesSPA verifies the RouteNotFound fallback serves
+// index.html for both the root path and unmatched client-side routes, while
+// registered routes stay untouched. Regression test for the echo v5
+// migration, where the router's not-found sentinel stopped matching
+// *echo.HTTPError and every page load returned a 500.
+func TestRegisterFrontend_ServesSPA(t *testing.T) {
+ e := echo.New()
+ e.GET("/api/health", func(c *echo.Context) error {
+ return c.String(http.StatusOK, "ok")
+ })
+ require.NoError(t, RegisterFrontend(e))
+
+ for _, path := range []string{"/", "/containers/some-id"} {
+ rec := httptest.NewRecorder()
+ e.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, path, nil))
+ require.Equal(t, http.StatusOK, rec.Code, "path %s", path)
+ require.Contains(t, rec.Body.String(), "<!doctype html", "path %s should serve index.html", path)
+ }
+
+ rec := httptest.NewRecorder()
+ e.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/api/health", nil))
+ require.Equal(t, http.StatusOK, rec.Code)
+ require.True(t, strings.HasPrefix(rec.Body.String(), "ok"))
+}
diff --git a/backend/go.mod b/backend/go.mod
index 7d30be058..d1efaf303 100644
--- a/backend/go.mod
+++ b/backend/go.mod
@@ -18,7 +18,7 @@ require (
github.com/containerd/errdefs v1.0.0
github.com/containerd/platforms v1.0.0-rc.4
github.com/coreos/go-oidc/v3 v3.20.0
- github.com/danielgtaylor/huma/v2 v2.38.0
+ github.com/danielgtaylor/huma/v2 v2.39.0
github.com/distribution/reference v0.6.0
github.com/docker/cli v29.6.2+incompatible
github.com/docker/compose/v5 v5.3.1
@@ -34,7 +34,7 @@ require (
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
github.com/jinzhu/copier v0.4.0
github.com/klauspost/compress v1.19.1
- github.com/labstack/echo/v4 v4.15.4
+ github.com/labstack/echo/v5 v5.3.1
github.com/libtnb/sqlite v1.2.0
github.com/lmittmann/tint v1.2.0
github.com/moby/buildkit v0.31.2
@@ -48,7 +48,7 @@ require (
github.com/robfig/cron/v3 v3.0.1
github.com/samber/hot v0.13.0
github.com/samber/mo v1.17.0
- github.com/samber/slog-echo v1.23.0
+ github.com/samber/slog-echo/v2 v2.0.0
github.com/shirou/gopsutil/v4 v4.26.6
github.com/spf13/cobra v1.10.2
github.com/stretchr/testify v1.11.1
@@ -154,6 +154,7 @@ require (
github.com/jonboulle/clockwork v0.5.0 // indirect
github.com/kevinburke/ssh_config v1.6.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
+ github.com/labstack/echo/v4 v4.15.4 // indirect
github.com/labstack/gommon v0.5.0 // indirect
github.com/lufia/plan9stats v0.0.0-20260330125221-c963978e514e // indirect
github.com/mattn/go-colorable v0.1.15 // indirect
diff --git a/backend/go.sum b/backend/go.sum
index 791e40a2e..bb696c0f9 100644
--- a/backend/go.sum
+++ b/backend/go.sum
@@ -122,8 +122,8 @@ github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467 h
github.com/cyberphone/json-canonicalization v0.0.0-20241213102144-19d51d7fe467/go.mod h1:uzvlm1mxhHkdfqitSA92i7Se+S9ksOn3a3qmv/kyOCw=
github.com/cyphar/filepath-securejoin v0.6.1 h1:5CeZ1jPXEiYt3+Z6zqprSAgSWiggmpVyciv8syjIpVE=
github.com/cyphar/filepath-securejoin v0.6.1/go.mod h1:A8hd4EnAeyujCJRrICiOWqjS1AX0a9kM5XL+NwKoYSc=
-github.com/danielgtaylor/huma/v2 v2.38.0 h1:fb0WZCatnaiHLphMQDDWDjygNxfMkX/ENma3QsRl7vY=
-github.com/danielgtaylor/huma/v2 v2.38.0/go.mod h1:k9hwjlgWFt1t2jsmQGlsgXAG2FBTZa4kkjV581qAtfo=
+github.com/danielgtaylor/huma/v2 v2.39.0 h1:YiXbzhJBSeQVkKbhn8adZR48Ei4XFx/K6jShQ3O92qU=
+github.com/danielgtaylor/huma/v2 v2.39.0/go.mod h1:pGstQdMhQnP9ZBnrqPRb9goqOWs1HU1uQewKWmkJOAY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
@@ -176,10 +176,12 @@ github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx5
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw=
github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
-github.com/fxamacker/cbor/v2 v2.9.1 h1:2rWm8B193Ll4VdjsJY28jxs70IdDsHRWgQYAI80+rMQ=
-github.com/fxamacker/cbor/v2 v2.9.1/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
+github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78=
+github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
+github.com/go-chi/chi/v5 v5.3.0 h1:halUjDxhshgXHMrao5bB8eNBXo/rnzwr8m5m36glehM=
+github.com/go-chi/chi/v5 v5.3.0/go.mod h1:R+tYY2hNuVUUjxoPtqUdgBqevM9s9njzkTLutVsOCto=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.9.0 h1:jItGXszUDRtR/AlferWPTMN4j38BQ88XnXKbilmmBPA=
@@ -327,6 +329,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/labstack/echo/v4 v4.15.4 h1:DL45vVYa+BWE+XuW+zZNd9H0YEdZ80UAWJGcTVW4EVs=
github.com/labstack/echo/v4 v4.15.4/go.mod h1:CuMetKIRwsuO/qlAgMq+KTAalwGoB/h4tC+yPdrTj1g=
+github.com/labstack/echo/v5 v5.3.1 h1:75maCxkQVGualckLc/5s/ihgpH1a1Dc6AuGWNVNs6bw=
+github.com/labstack/echo/v5 v5.3.1/go.mod h1:4iEGNQiPPZnkfYpNR/L6fINd3NLiGWUD5+eBotFALas=
github.com/labstack/gommon v0.5.0 h1:6VSQ2NOzsnEJ5W6+84E0RbcaDDmgB6NIAzWCczTEe6c=
github.com/labstack/gommon v0.5.0/go.mod h1:Rzlg7HHy1maLfzBYGg9NZcVuz1sA68HHhLjhcEllYE0=
github.com/libtnb/sqlite v1.2.0 h1:XsA7jsXHH2qmFkTWoy5YCKJybzHzWQ0flqDFP5Y9Yto=
@@ -445,8 +449,8 @@ github.com/samber/lo v1.53.0 h1:t975lj2py4kJPQ6haz1QMgtId2gtmfktACxIXArw3HM=
github.com/samber/lo v1.53.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
github.com/samber/mo v1.17.0 h1:EbeLc7nxIdpalstxQQakLOcXxULuMRqo7PJPtY18bQg=
github.com/samber/mo v1.17.0/go.mod h1:DlgzJ4SYhOh41nP1L9kh9rDNERuf8IqWSAs+gj2Vxag=
-github.com/samber/slog-echo v1.23.0 h1:jFzK9t9hLvEjic2tfIkgXt2r22Zz2UYaYrUyM/S0pks=
-github.com/samber/slog-echo v1.23.0/go.mod h1:caG3zeXgrPRlGKaPVqyWG1MEc6nwrmtDjoLN/mc0PrM=
+github.com/samber/slog-echo/v2 v2.0.0 h1:VLUOug7P/qiEO/uyHIxqGZWnlYczZSUBzInewnvzCck=
+github.com/samber/slog-echo/v2 v2.0.0/go.mod h1:62kVIOBLr3qx9dIcUMlS+zu7e5YN3aKX4LzTdQUnDFs=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
github.com/secure-systems-lab/go-securesystemslib v0.11.0 h1:iuCR9kcMFD4QurdKrGvPLoKZLv9YvwPYVr0473BdtFs=
diff --git a/backend/internal/bootstrap/bootstrap.go b/backend/internal/bootstrap/bootstrap.go
index 3ef5fd471..90bc57e1e 100644
--- a/backend/internal/bootstrap/bootstrap.go
+++ b/backend/internal/bootstrap/bootstrap.go
@@ -23,7 +23,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/startup"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
httputils "github.com/getarcaneapp/arcane/backend/v2/pkg/utils/httpx"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"go.getarcane.app/streams/logs"
libcrypto "go.getarcane.app/sys/crypto"
"go.uber.org/fx"
diff --git a/backend/internal/bootstrap/bootstrap_test.go b/backend/internal/bootstrap/bootstrap_test.go
index 771cd73b1..9f4d751af 100644
--- a/backend/internal/bootstrap/bootstrap_test.go
+++ b/backend/internal/bootstrap/bootstrap_test.go
@@ -17,7 +17,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/database"
"github.com/getarcaneapp/arcane/backend/v2/internal/middleware"
tunnelpb "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge/proto/tunnel/v1"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
libcrypto "go.getarcane.app/sys/crypto"
@@ -243,10 +243,10 @@ func TestHTTPServerStopCancelsStreamingRequestContextsInternal(t *testing.T) {
handlerEntered := make(chan struct{})
router := echo.New()
- router.GET("/stream", func(c echo.Context) error {
+ router.GET("/stream", func(c *echo.Context) error {
c.Response().Header().Set("Content-Type", "application/x-json-stream")
c.Response().WriteHeader(http.StatusOK)
- c.Response().Flush()
+ c.Response().(http.Flusher).Flush()
close(handlerEntered)
<-c.Request().Context().Done()
return nil
diff --git a/backend/internal/bootstrap/buildables_router_bootstrap.go b/backend/internal/bootstrap/buildables_router_bootstrap.go
index 637837ba2..0969c5099 100644
--- a/backend/internal/bootstrap/buildables_router_bootstrap.go
+++ b/backend/internal/bootstrap/buildables_router_bootstrap.go
@@ -4,7 +4,7 @@ package bootstrap
import (
"github.com/getarcaneapp/arcane/backend/v2/api"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
func init() {
diff --git a/backend/internal/bootstrap/edge_bootstrap.go b/backend/internal/bootstrap/edge_bootstrap.go
index 4c3b7bb44..308ace148 100644
--- a/backend/internal/bootstrap/edge_bootstrap.go
+++ b/backend/internal/bootstrap/edge_bootstrap.go
@@ -13,7 +13,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/models"
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
// registerEdgeTunnelRoutes configures the manager-side edge tunnel server.
diff --git a/backend/internal/bootstrap/playwright_router_bootstrap.go b/backend/internal/bootstrap/playwright_router_bootstrap.go
index 9f094a9cd..16666a934 100644
--- a/backend/internal/bootstrap/playwright_router_bootstrap.go
+++ b/backend/internal/bootstrap/playwright_router_bootstrap.go
@@ -7,7 +7,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/api"
"github.com/getarcaneapp/arcane/backend/v2/internal/services"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
func init() {
diff --git a/backend/internal/bootstrap/router_bootstrap.go b/backend/internal/bootstrap/router_bootstrap.go
index aa7992ccf..b9ab33885 100644
--- a/backend/internal/bootstrap/router_bootstrap.go
+++ b/backend/internal/bootstrap/router_bootstrap.go
@@ -10,9 +10,9 @@ import (
"emperror.dev/errors"
- "github.com/labstack/echo/v4"
- echomiddleware "github.com/labstack/echo/v4/middleware"
- slogecho "github.com/samber/slog-echo"
+ "github.com/labstack/echo/v5"
+ echomiddleware "github.com/labstack/echo/v5/middleware"
+ slogecho "github.com/samber/slog-echo/v2"
"github.com/getarcaneapp/arcane/backend/v2/api"
"github.com/getarcaneapp/arcane/backend/v2/api/handlers"
@@ -49,7 +49,7 @@ var loggerSkipPatterns = []string{
"GET /api/app-images/*",
}
-func shouldLogRequestInternal(c echo.Context) bool {
+func shouldLogRequestInternal(c *echo.Context, _ error) bool {
mp := c.Request().Method + " " + c.Request().URL.Path
for _, pat := range loggerSkipPatterns {
if pat == mp {
@@ -81,7 +81,7 @@ func requestLoggerMiddlewareInternal() echo.MiddlewareFunc {
})
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
if edge.IsInternalTunnelRequest(c.Request().Context()) {
return next(c)
}
@@ -110,7 +110,7 @@ func createAuthValidatorInternal(deps api.HandlerDeps) middleware.AuthValidator
}
return ps
}
- return func(ctx context.Context, c echo.Context) (*authz.PermissionSet, bool) {
+ return func(ctx context.Context, c *echo.Context) (*authz.PermissionSet, bool) {
req := c.Request()
// Check for API key authentication
if apiKey := req.Header.Get("X-Api-Key"); apiKey != "" {
@@ -165,8 +165,6 @@ func newRouter(p RouterParams) (*echo.Echo, *edge.TunnelServer) {
deps := p.HandlerDeps
e := echo.New()
- e.HideBanner = true
- e.HidePort = true
trustedProxyNets := parseTrustedProxyCIDRsInternal(cfg.TrustedProxies)
if cfg.TrustedProxies != "" && len(trustedProxyNets) == 0 {
@@ -262,6 +260,20 @@ func newRouter(p RouterParams) (*echo.Echo, *edge.TunnelServer) {
}
}
+ // Unknown API endpoints respond with JSON 404. This must be registered
+ // after every apiGroup.Use call: each Use re-registers the group's
+ // auto-404 routes, which would overwrite these. Without an explicit
+ // handler those auto-404 routes return echo v5's unexported sentinel
+ // error, which slog-echo rewrites into a 500.
+ apiNotFound := func(c *echo.Context) error {
+ return c.JSON(http.StatusNotFound, map[string]any{
+ "success": false,
+ "error": "API endpoint not found: " + c.Request().URL.Path,
+ })
+ }
+ apiGroup.RouteNotFound("", apiNotFound)
+ apiGroup.RouteNotFound("/*", apiNotFound)
+
if err := frontend.RegisterFrontend(e); err != nil {
if errors.Is(err, frontend.ErrFrontendNotIncluded) {
slog.Debug("Frontend not included in this build; skipping frontend registration")
@@ -302,7 +314,7 @@ func parseTrustedProxyCIDRsInternal(raw string) []*net.IPNet {
// __Host- cookies over plain HTTP.
func secureCookieContextMiddlewareInternal(trustedProxyNets []*net.IPNet) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
req := c.Request()
secure := req.TLS != nil
if !secure && len(trustedProxyNets) > 0 &&
diff --git a/backend/internal/bootstrap/router_bootstrap_test.go b/backend/internal/bootstrap/router_bootstrap_test.go
index 5b31f247f..624d1699f 100644
--- a/backend/internal/bootstrap/router_bootstrap_test.go
+++ b/backend/internal/bootstrap/router_bootstrap_test.go
@@ -6,7 +6,7 @@ import (
"testing"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils/cookie"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
)
@@ -29,7 +29,7 @@ func TestSecureCookieContextMiddleware_TrustGating(t *testing.T) {
c := e.NewContext(req, rec)
var observed bool
- handler := secureCookieContextMiddlewareInternal(nets)(func(c echo.Context) error {
+ handler := secureCookieContextMiddlewareInternal(nets)(func(c *echo.Context) error {
observed = cookie.SecureCookieFromContext(c.Request().Context())
return nil
})
diff --git a/backend/internal/bootstrap/server_bootstrap.go b/backend/internal/bootstrap/server_bootstrap.go
index 4298bc6a1..3a5b9dce5 100644
--- a/backend/internal/bootstrap/server_bootstrap.go
+++ b/backend/internal/bootstrap/server_bootstrap.go
@@ -14,7 +14,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/config"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge"
tunnelpb "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge/proto/tunnel/v1"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"go.uber.org/fx"
"google.golang.org/grpc"
)
diff --git a/backend/internal/middleware/auth_middleware.go b/backend/internal/middleware/auth_middleware.go
index 5f2040e9d..5cc07f26a 100644
--- a/backend/internal/middleware/auth_middleware.go
+++ b/backend/internal/middleware/auth_middleware.go
@@ -18,7 +18,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
pkgutils "github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
"github.com/getarcaneapp/arcane/backend/v2/pkg/utils/cookie"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
// Echo context keys, kept aligned with api/middleware/auth.go constants so
@@ -105,7 +105,7 @@ func (m *AuthMiddleware) WithAdminRequired() *AuthMiddleware {
// AuthMiddleware (i.e., chain it AFTER auth).
func RequirePermission(perm string) echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
ps, _ := c.Get(echoCtxKeyUserPermissions).(*authz.PermissionSet)
envID := ""
if authz.IsEnvScoped(perm) {
@@ -124,7 +124,7 @@ func RequirePermission(perm string) echo.MiddlewareFunc {
func (m *AuthMiddleware) Add() echo.MiddlewareFunc {
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
reqCtx := c.Request().Context()
if m.cfg != nil && m.cfg.AgentMode {
return m.agentAuth(reqCtx, c, next)
@@ -134,7 +134,7 @@ func (m *AuthMiddleware) Add() echo.MiddlewareFunc {
}
}
-func (m *AuthMiddleware) agentAuth(ctx context.Context, c echo.Context, next echo.HandlerFunc) error {
+func (m *AuthMiddleware) agentAuth(ctx context.Context, c *echo.Context, next echo.HandlerFunc) error {
if isPreflightInternal(c) {
return next(c)
}
@@ -179,7 +179,7 @@ func agentTokenMatchesInternal(presented, configured string) bool {
return subtle.ConstantTimeCompare([]byte(presented), []byte(configured)) == 1
}
-func (m *AuthMiddleware) managerAuth(ctx context.Context, c echo.Context, next echo.HandlerFunc) error {
+func (m *AuthMiddleware) managerAuth(ctx context.Context, c *echo.Context, next echo.HandlerFunc) error {
req := c.Request()
if agentToken := req.Header.Get(pkgutils.HeaderAgentToken); agentToken != "" {
if env, ok := m.resolveEnvironmentAccessToken(ctx, agentToken).Get(); ok {
@@ -217,7 +217,7 @@ func (m *AuthMiddleware) managerAuth(ctx context.Context, c echo.Context, next e
}
if errors.Is(err, common.ErrSessionRevoked) || errors.Is(err, common.ErrTokenValidation) {
- cookie.ClearTokenCookie(c.Response().Writer, req)
+ cookie.ClearTokenCookie(c.Response(), req)
return c.JSON(http.StatusUnauthorized, models.APIError{
Code: models.APIErrorCodeUnauthorized,
Message: "Session expired. Please log in again.",
@@ -250,7 +250,7 @@ func (m *AuthMiddleware) managerAuth(ctx context.Context, c echo.Context, next e
// apiKeyHeaderAuth authenticates an X-API-Key credential: a user-owned API key
// first, then an environment access token presented through the same header.
-func (m *AuthMiddleware) apiKeyHeaderAuth(ctx context.Context, c echo.Context, next echo.HandlerFunc, apiKey string) error {
+func (m *AuthMiddleware) apiKeyHeaderAuth(ctx context.Context, c *echo.Context, next echo.HandlerFunc, apiKey string) error {
if m.apiKeyValidator != nil {
user, key, err := m.apiKeyValidator.ValidateApiKeyWithID(ctx, apiKey)
if err == nil && user != nil {
@@ -328,11 +328,11 @@ func (m *AuthMiddleware) resolveEnvironmentAccessToken(ctx context.Context, toke
return mo.Some(env)
}
-func isPreflightInternal(c echo.Context) bool {
+func isPreflightInternal(c *echo.Context) bool {
return c.Request().Method == http.MethodOptions
}
-func agentSudoInternal(c echo.Context) {
+func agentSudoInternal(c *echo.Context) {
agentUser := &models.User{
BaseModel: models.BaseModel{ID: "agent"},
Email: new("[email protected]"),
@@ -344,7 +344,7 @@ func agentSudoInternal(c echo.Context) {
c.Set(echoCtxKeyAuthMethod, "agent_token")
}
-func environmentScopedInternal(c echo.Context, env *models.Environment) {
+func environmentScopedInternal(c *echo.Context, env *models.Environment) {
envUser := &models.User{
BaseModel: models.BaseModel{ID: "environment:" + env.ID},
Username: env.Name,
@@ -355,7 +355,7 @@ func environmentScopedInternal(c echo.Context, env *models.Environment) {
c.Set(echoCtxKeyAuthMethod, "environment_access_token")
}
-func extractBearerOrCookieTokenInternal(c echo.Context) string {
+func extractBearerOrCookieTokenInternal(c *echo.Context) string {
req := c.Request()
authHeader := req.Header.Get("Authorization")
if after, ok := strings.CutPrefix(authHeader, "Bearer "); ok {
diff --git a/backend/internal/middleware/auth_middleware_test.go b/backend/internal/middleware/auth_middleware_test.go
index be4d91c0d..98933140d 100644
--- a/backend/internal/middleware/auth_middleware_test.go
+++ b/backend/internal/middleware/auth_middleware_test.go
@@ -9,7 +9,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/config"
"github.com/getarcaneapp/arcane/backend/v2/internal/models"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/require"
)
@@ -80,7 +80,7 @@ func TestAuthMiddleware_ManagerAuthResolvesPermissionsByKeyKind(t *testing.T) {
WithPermissionResolver(testPermissionResolver{}).
Add(),
)
- router.GET("/secure", func(c echo.Context) error {
+ router.GET("/secure", func(c *echo.Context) error {
ps, ok := c.Get("userPermissions").(*authz.PermissionSet)
require.True(t, ok)
require.True(t, ps.Allows(tc.wantAllowed, ""))
@@ -112,7 +112,7 @@ func TestAuthMiddleware_ManagerAuthAcceptsEnvironmentAccessTokenViaAPIKey(t *tes
}).
Add(),
)
- router.GET("/secure", func(c echo.Context) error {
+ router.GET("/secure", func(c *echo.Context) error {
currentUser := c.Get("currentUser")
require.NotNil(t, currentUser)
diff --git a/backend/internal/middleware/cors_middleware.go b/backend/internal/middleware/cors_middleware.go
index fb5a8638b..863057e79 100644
--- a/backend/internal/middleware/cors_middleware.go
+++ b/backend/internal/middleware/cors_middleware.go
@@ -6,8 +6,8 @@ import (
"strings"
"github.com/getarcaneapp/arcane/backend/v2/internal/config"
- "github.com/labstack/echo/v4"
- echomiddleware "github.com/labstack/echo/v4/middleware"
+ "github.com/labstack/echo/v5"
+ echomiddleware "github.com/labstack/echo/v5/middleware"
)
type CORSMiddleware struct {
@@ -24,7 +24,7 @@ func (m *CORSMiddleware) Add() echo.MiddlewareFunc {
// requests through the edge tunnel from the manager — never from browsers.
if m.cfg != nil && m.cfg.EdgeAgent {
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error { return next(c) }
+ return func(c *echo.Context) error { return next(c) }
}
}
diff --git a/backend/internal/middleware/csrf_middleware.go b/backend/internal/middleware/csrf_middleware.go
index d935bdc5b..e347b6216 100644
--- a/backend/internal/middleware/csrf_middleware.go
+++ b/backend/internal/middleware/csrf_middleware.go
@@ -8,7 +8,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/internal/config"
"github.com/getarcaneapp/arcane/backend/v2/internal/models"
pkgutils "github.com/getarcaneapp/arcane/backend/v2/pkg/utils"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
// publicCrossOriginBypassPaths are endpoints intentionally reachable cross-origin
@@ -42,7 +42,7 @@ func (m *CSRFMiddleware) Add() echo.MiddlewareFunc {
// through the edge tunnel from the manager — never from browsers. Mirrors CORSMiddleware.
if m.cfg != nil && m.cfg.EdgeAgent {
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error { return next(c) }
+ return func(c *echo.Context) error { return next(c) }
}
}
@@ -59,7 +59,7 @@ func (m *CSRFMiddleware) Add() echo.MiddlewareFunc {
}
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
req := c.Request()
if hasHeaderCredentialInternal(req) {
return next(c)
diff --git a/backend/internal/middleware/csrf_middleware_test.go b/backend/internal/middleware/csrf_middleware_test.go
index 0b2dd1d19..5371b549d 100644
--- a/backend/internal/middleware/csrf_middleware_test.go
+++ b/backend/internal/middleware/csrf_middleware_test.go
@@ -6,7 +6,7 @@ import (
"testing"
"github.com/getarcaneapp/arcane/backend/v2/internal/config"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/require"
)
@@ -14,8 +14,8 @@ func newCSRFTestRouterInternal() *echo.Echo {
cfg := &config.Config{Environment: "production", AppUrl: "https://arcane.example.com"}
router := echo.New()
router.Use(NewCSRFMiddleware(cfg).Add())
- router.POST("/api/test", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
- router.POST("/api/webhooks/trigger/:token", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
+ router.POST("/api/test", func(c *echo.Context) error { return c.NoContent(http.StatusOK) })
+ router.POST("/api/webhooks/trigger/:token", func(c *echo.Context) error { return c.NoContent(http.StatusOK) })
return router
}
diff --git a/backend/internal/middleware/environment_middleware.go b/backend/internal/middleware/environment_middleware.go
index 009c567d5..ea51d580b 100644
--- a/backend/internal/middleware/environment_middleware.go
+++ b/backend/internal/middleware/environment_middleware.go
@@ -19,7 +19,7 @@ import (
wsutil "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/ws"
httputils "github.com/getarcaneapp/arcane/backend/v2/pkg/utils/httpx"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
const (
@@ -54,7 +54,7 @@ type EnvResolver func(ctx context.Context, id string) (string, *string, bool, er
// request is authenticated; the permission set is used to authorize proxied
// requests against the target environment. Sudo permission sets (internal
// agent proxies) bypass authorization.
-type AuthValidator func(ctx context.Context, c echo.Context) (*authz.PermissionSet, bool)
+type AuthValidator func(ctx context.Context, c *echo.Context) (*authz.PermissionSet, bool)
// EnvironmentMiddleware proxies requests for remote environments to their respective agents.
type EnvironmentMiddleware struct {
@@ -95,14 +95,14 @@ func NewEnvProxyMiddlewareWithParamAndRegistry(
matcher: matcher,
}
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
return m.Handle(c, next)
}
}
}
// Handle is the main middleware handler.
-func (m *EnvironmentMiddleware) Handle(c echo.Context, next echo.HandlerFunc) error {
+func (m *EnvironmentMiddleware) Handle(c *echo.Context, next echo.HandlerFunc) error {
envID := m.extractEnvironmentID(c)
if envID == "" || envID == m.localID {
@@ -185,7 +185,7 @@ func (m *EnvironmentMiddleware) Handle(c echo.Context, next echo.HandlerFunc) er
// Sudo callers bypass the check. Requests whose (method, path) has no known
// permission mapping are denied (default-deny), so a newly added proxied route
// cannot silently bypass authorization before it is mapped.
-func (m *EnvironmentMiddleware) proxyPermissionDenied(c echo.Context, ps *authz.PermissionSet, envID string) bool {
+func (m *EnvironmentMiddleware) proxyPermissionDenied(c *echo.Context, ps *authz.PermissionSet, envID string) bool {
if m.matcher == nil {
return false
}
@@ -219,7 +219,7 @@ func (m *EnvironmentMiddleware) proxyPermissionDenied(c echo.Context, ps *authz.
return false
}
-func (m *EnvironmentMiddleware) proxyActiveEdgeTunnelInternal(c echo.Context, envID string, accessToken *string) (bool, error) {
+func (m *EnvironmentMiddleware) proxyActiveEdgeTunnelInternal(c *echo.Context, envID string, accessToken *string) (bool, error) {
tunnel, ok := m.getActiveEdgeTunnelInternal(envID).Get()
if !ok {
return false, nil
@@ -230,7 +230,7 @@ func (m *EnvironmentMiddleware) proxyActiveEdgeTunnelInternal(c echo.Context, en
return true, m.proxyThroughTunnelInternal(c, tunnel, envID)
}
-func (m *EnvironmentMiddleware) proxyRecoveredEdgeTunnelInternal(c echo.Context, envID string, accessToken *string) (bool, error) {
+func (m *EnvironmentMiddleware) proxyRecoveredEdgeTunnelInternal(c *echo.Context, envID string, accessToken *string) (bool, error) {
edge.TouchTunnelDemand(envID, edge.DefaultTunnelDemandTTL)
tunnel, ok := m.waitForActiveEdgeTunnelInternal(c.Request().Context(), envID, edge.DefaultTunnelAcquireTimeout()).Get()
@@ -243,14 +243,14 @@ func (m *EnvironmentMiddleware) proxyRecoveredEdgeTunnelInternal(c echo.Context,
return true, m.proxyThroughTunnelInternal(c, tunnel, envID)
}
-func (m *EnvironmentMiddleware) setProxyContextHeadersInternal(c echo.Context, accessToken *string) {
+func (m *EnvironmentMiddleware) setProxyContextHeadersInternal(c *echo.Context, accessToken *string) {
if accessToken != nil && *accessToken != "" {
c.Request().Header.Set(edge.HeaderAgentToken, *accessToken)
c.Request().Header.Set(edge.HeaderAPIKey, *accessToken)
}
}
-func (m *EnvironmentMiddleware) proxyThroughTunnelInternal(c echo.Context, tunnel *edge.AgentTunnel, envID string) error {
+func (m *EnvironmentMiddleware) proxyThroughTunnelInternal(c *echo.Context, tunnel *edge.AgentTunnel, envID string) error {
proxyPath := m.buildProxyPath(c, envID)
if m.isWebSocketUpgrade(c) {
return edge.ProxyWebSocketRequest(c, tunnel, proxyPath)
@@ -259,7 +259,7 @@ func (m *EnvironmentMiddleware) proxyThroughTunnelInternal(c echo.Context, tunne
}
// hasResourcePath reports whether the request targets a proxiable resource path.
-func (m *EnvironmentMiddleware) hasResourcePath(c echo.Context, envID string) bool {
+func (m *EnvironmentMiddleware) hasResourcePath(c *echo.Context, envID string) bool {
suffix, ok := strings.CutPrefix(c.Request().URL.Path, apiEnvironmentsPrefix+envID)
if !ok || len(suffix) <= 1 || suffix[0] != '/' {
return false
@@ -318,7 +318,7 @@ func isCentralSwarmManagementPathInternal(method, suffix string) bool {
}
// extractEnvironmentID gets the environment ID from the request.
-func (m *EnvironmentMiddleware) extractEnvironmentID(c echo.Context) string {
+func (m *EnvironmentMiddleware) extractEnvironmentID(c *echo.Context) string {
requestPath := c.Request().URL.Path
if !strings.Contains(requestPath, environmentsPathMarker) {
@@ -348,7 +348,7 @@ func (m *EnvironmentMiddleware) buildResourceSuffix(requestPath, envID string) s
}
// buildTargetURL constructs the full proxy target URL for a remote environment.
-func (m *EnvironmentMiddleware) buildTargetURL(c echo.Context, envID, apiURL string) string {
+func (m *EnvironmentMiddleware) buildTargetURL(c *echo.Context, envID, apiURL string) string {
req := c.Request()
suffix := m.buildResourceSuffix(req.URL.Path, envID)
target := strings.TrimRight(apiURL, "/") + path.Join(apiEnvironmentsPrefix, m.localID) + suffix
@@ -359,12 +359,12 @@ func (m *EnvironmentMiddleware) buildTargetURL(c echo.Context, envID, apiURL str
}
// buildProxyPath constructs the path sent through the edge tunnel.
-func (m *EnvironmentMiddleware) buildProxyPath(c echo.Context, envID string) string {
+func (m *EnvironmentMiddleware) buildProxyPath(c *echo.Context, envID string) string {
return path.Join(apiEnvironmentsPrefix, m.localID) + m.buildResourceSuffix(c.Request().URL.Path, envID)
}
// isWebSocketUpgrade checks if this is a WebSocket upgrade request.
-func (m *EnvironmentMiddleware) isWebSocketUpgrade(c echo.Context) bool {
+func (m *EnvironmentMiddleware) isWebSocketUpgrade(c *echo.Context) bool {
return websocket.IsWebSocketUpgrade(c.Request())
}
@@ -412,7 +412,7 @@ func (m *EnvironmentMiddleware) waitForActiveEdgeTunnelInternal(ctx context.Cont
}
}
-func (m *EnvironmentMiddleware) abortEdgeTunnelUnavailable(c echo.Context) error {
+func (m *EnvironmentMiddleware) abortEdgeTunnelUnavailable(c *echo.Context) error {
return c.JSON(http.StatusBadGateway, map[string]any{
"success": false,
"data": map[string]any{
@@ -422,7 +422,7 @@ func (m *EnvironmentMiddleware) abortEdgeTunnelUnavailable(c echo.Context) error
}
// proxyWebSocket handles WebSocket proxy requests.
-func (m *EnvironmentMiddleware) proxyWebSocket(c echo.Context, target string, accessToken *string, envID string) error {
+func (m *EnvironmentMiddleware) proxyWebSocket(c *echo.Context, target string, accessToken *string, envID string) error {
if isEdgeEnvironmentURLInternal(target) {
slog.WarnContext(c.Request().Context(), "Refusing direct websocket proxy to edge environment without active tunnel", "environment_id", envID, "target", target)
return m.abortEdgeTunnelUnavailable(c)
@@ -431,14 +431,14 @@ func (m *EnvironmentMiddleware) proxyWebSocket(c echo.Context, target string, ac
wsTarget := edge.HTTPToWebSocketURL(target)
headers := edge.BuildWebSocketHeaders(c, accessToken)
- if err := wsutil.ProxyHTTP(c.Response().Writer, c.Request(), wsTarget, headers); err != nil {
+ if err := wsutil.ProxyHTTP(c.Response(), c.Request(), wsTarget, headers); err != nil {
slog.Error("websocket proxy failed", "err", err)
}
return nil
}
// proxyHTTP handles standard HTTP proxy requests.
-func (m *EnvironmentMiddleware) proxyHTTP(c echo.Context, target string, accessToken *string) error {
+func (m *EnvironmentMiddleware) proxyHTTP(c *echo.Context, target string, accessToken *string) error {
if isEdgeEnvironmentURLInternal(target) {
slog.WarnContext(c.Request().Context(), "Refusing direct HTTP proxy to edge environment without active tunnel", "target", target)
return m.abortEdgeTunnelUnavailable(c)
@@ -470,7 +470,7 @@ func (m *EnvironmentMiddleware) proxyHTTP(c echo.Context, target string, accessT
}
// createProxyRequest builds the HTTP request to forward to the remote environment.
-func (m *EnvironmentMiddleware) createProxyRequest(c echo.Context, target string, accessToken *string) (*http.Request, error) {
+func (m *EnvironmentMiddleware) createProxyRequest(c *echo.Context, target string, accessToken *string) (*http.Request, error) {
srcReq := c.Request()
validatedTarget, err := httputils.ValidateOutboundHTTPURL(target)
if err != nil {
@@ -521,8 +521,8 @@ func (m *EnvironmentMiddleware) createProxyRequest(c echo.Context, target string
}
// writeProxyResponse copies the proxy response back to the client.
-func (m *EnvironmentMiddleware) writeProxyResponse(c echo.Context, resp *http.Response) {
- w := c.Response().Writer
+func (m *EnvironmentMiddleware) writeProxyResponse(c *echo.Context, resp *http.Response) {
+ w := c.Response()
hopByHop := edge.BuildHopByHopHeaders(resp.Header)
edge.CopyResponseHeaders(resp.Header, w.Header(), hopByHop)
diff --git a/backend/internal/middleware/environment_middleware_authz_test.go b/backend/internal/middleware/environment_middleware_authz_test.go
index 6c80126f6..a584e0572 100644
--- a/backend/internal/middleware/environment_middleware_authz_test.go
+++ b/backend/internal/middleware/environment_middleware_authz_test.go
@@ -5,7 +5,7 @@ import (
"net/http/httptest"
"testing"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
)
@@ -16,7 +16,7 @@ func newProxyAuthzMiddleware(matcher *authz.PermissionMatcher) *EnvironmentMiddl
return &EnvironmentMiddleware{localID: "0", paramName: "id", matcher: matcher}
}
-func newProxyRequestContext(method, path string) echo.Context {
+func newProxyRequestContext(method, path string) *echo.Context {
e := echo.New()
req := httptest.NewRequest(method, path, nil)
return e.NewContext(req, httptest.NewRecorder())
diff --git a/backend/internal/middleware/environment_middleware_test.go b/backend/internal/middleware/environment_middleware_test.go
index bb82feed4..7a56af4f4 100644
--- a/backend/internal/middleware/environment_middleware_test.go
+++ b/backend/internal/middleware/environment_middleware_test.go
@@ -8,7 +8,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/authz"
"github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
)
@@ -20,7 +20,7 @@ func newTestEnvironmentMiddleware() *EnvironmentMiddleware {
_ = ctx
return "edge://oracle-1", nil, true, nil
},
- authValidator: func(ctx context.Context, c echo.Context) (*authz.PermissionSet, bool) {
+ authValidator: func(ctx context.Context, c *echo.Context) (*authz.PermissionSet, bool) {
_ = ctx
_ = c
return authz.SudoPermissionSet(), true
@@ -33,7 +33,7 @@ func newTestEnvironmentMiddleware() *EnvironmentMiddleware {
func attachMiddleware(router *echo.Echo, mw *EnvironmentMiddleware) *echo.Group {
api := router.Group("/api")
api.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
return mw.Handle(c, next)
}
})
@@ -46,7 +46,7 @@ func TestEnvironmentMiddleware_ReturnsBadGatewayForEdgeResourcesWithoutTunnel(t
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.GET("/environments/:id/containers", func(c echo.Context) error {
+ api.GET("/environments/:id/containers", func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -67,7 +67,7 @@ func TestEnvironmentMiddleware_ProxiesDashboardResourcesForRemoteEnvironments(t
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.GET("/environments/:id/dashboard", func(c echo.Context) error {
+ api.GET("/environments/:id/dashboard", func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -88,7 +88,7 @@ func TestEnvironmentMiddleware_KeepsEdgeManagementEndpointsLocal(t *testing.T) {
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.GET("/environments/:id/settings", func(c echo.Context) error {
+ api.GET("/environments/:id/settings", func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -109,7 +109,7 @@ func TestEnvironmentMiddleware_KeepsEdgeMTLSDownloadEndpointsLocal(t *testing.T)
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.GET("/environments/:id/deployment/mtls/bundle", func(c echo.Context) error {
+ api.GET("/environments/:id/deployment/mtls/bundle", func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -130,7 +130,7 @@ func TestEnvironmentMiddleware_KeepsNotificationEndpointsLocal(t *testing.T) {
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.GET("/environments/:id/notifications/settings", func(c echo.Context) error {
+ api.GET("/environments/:id/notifications/settings", func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -173,7 +173,7 @@ func TestEnvironmentMiddleware_KeepsWebhookEndpointsLocal(t *testing.T) {
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.Add(tt.method, tt.route, func(c echo.Context) error {
+ api.Add(tt.method, tt.route, func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -212,7 +212,7 @@ func TestEnvironmentMiddleware_KeepsActivityEndpointsLocal(t *testing.T) {
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.Add(tt.method, tt.route, func(c echo.Context) error {
+ api.Add(tt.method, tt.route, func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -243,7 +243,7 @@ func TestEnvironmentMiddleware_LocalEnvironmentSkipsProxyPermissionCheck(t *test
localID: "0",
paramName: "id",
matcher: matcher,
- authValidator: func(ctx context.Context, c echo.Context) (*authz.PermissionSet, bool) {
+ authValidator: func(ctx context.Context, c *echo.Context) (*authz.PermissionSet, bool) {
_ = ctx
_ = c
return authz.NewPermissionSet(), true
@@ -256,7 +256,7 @@ func TestEnvironmentMiddleware_LocalEnvironmentSkipsProxyPermissionCheck(t *test
api := attachMiddleware(router, mw)
localHandlerHit := false
- api.GET("/environments/:id/containers", func(c echo.Context) error {
+ api.GET("/environments/:id/containers", func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
@@ -374,7 +374,7 @@ func TestEnvironmentMiddleware_KeepsNodeAgentDeploymentCreationLocal(t *testing.
api := attachMiddleware(router, middleware)
localHandlerHit := false
- api.POST("/environments/:id/swarm/nodes/:nodeId/agent/deployment", func(c echo.Context) error {
+ api.POST("/environments/:id/swarm/nodes/:nodeId/agent/deployment", func(c *echo.Context) error {
localHandlerHit = true
return c.JSON(http.StatusOK, map[string]any{"success": true})
})
diff --git a/backend/internal/middleware/rate_limit_middleware.go b/backend/internal/middleware/rate_limit_middleware.go
index 8da33c45b..cfcad5037 100644
--- a/backend/internal/middleware/rate_limit_middleware.go
+++ b/backend/internal/middleware/rate_limit_middleware.go
@@ -10,7 +10,7 @@ import (
"sync"
"time"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"golang.org/x/time/rate"
)
@@ -119,7 +119,7 @@ func PerIPRateLimit(perMinute int, burst int) echo.MiddlewareFunc {
limiter := newIPRateLimiterInternal(rate.Every(time.Minute/time.Duration(perMinute)), burst)
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
key := clientIPForRateLimitInternal(c)
if !limiter.allow(key) {
c.Response().Header().Set("Retry-After", "60")
@@ -142,7 +142,7 @@ func PerAgentTokenRateLimit(perMinute int, burst int) echo.MiddlewareFunc {
limiter := newIPRateLimiterInternal(rate.Every(time.Minute/time.Duration(perMinute)), burst)
return func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
req := c.Request()
key := strings.TrimSpace(req.Header.Get("X-Arcane-Agent-Token"))
if key == "" {
@@ -180,7 +180,7 @@ func PerIPRateLimitForPaths(paths []string, perMinute int, burst int) echo.Middl
for p, rl := range limiters {
gatedByPath[p] = rl(next)
}
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
gated, ok := gatedByPath[c.Path()]
if !ok {
return next(c)
@@ -190,7 +190,7 @@ func PerIPRateLimitForPaths(paths []string, perMinute int, burst int) echo.Middl
}
}
-func clientIPForRateLimitInternal(c echo.Context) string {
+func clientIPForRateLimitInternal(c *echo.Context) string {
if ip := strings.TrimSpace(c.RealIP()); ip != "" {
return ip
}
diff --git a/backend/internal/middleware/rate_limit_middleware_test.go b/backend/internal/middleware/rate_limit_middleware_test.go
index f88525bb7..e1541d368 100644
--- a/backend/internal/middleware/rate_limit_middleware_test.go
+++ b/backend/internal/middleware/rate_limit_middleware_test.go
@@ -6,14 +6,14 @@ import (
"testing"
"time"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/require"
"golang.org/x/time/rate"
)
func TestPerIPRateLimit_AllowsUnderBurstAndBlocksOver(t *testing.T) {
router := echo.New()
- router.POST("/t", func(c echo.Context) error {
+ router.POST("/t", func(c *echo.Context) error {
return c.NoContent(http.StatusOK)
}, PerIPRateLimit(60, 2))
@@ -32,7 +32,7 @@ func TestPerIPRateLimit_AllowsUnderBurstAndBlocksOver(t *testing.T) {
func TestPerIPRateLimit_TracksDistinctClients(t *testing.T) {
router := echo.New()
- router.POST("/t", func(c echo.Context) error {
+ router.POST("/t", func(c *echo.Context) error {
return c.NoContent(http.StatusOK)
}, PerIPRateLimit(60, 1))
@@ -51,7 +51,7 @@ func TestPerIPRateLimit_TracksDistinctClients(t *testing.T) {
func TestStackedAgentEnrollmentRateLimits_KeepIPBackPressure(t *testing.T) {
router := echo.New()
- router.POST("/t", func(c echo.Context) error {
+ router.POST("/t", func(c *echo.Context) error {
return c.NoContent(http.StatusOK)
}, PerIPRateLimit(60, 1), PerAgentTokenRateLimit(60, 10))
@@ -73,10 +73,10 @@ func TestPerIPRateLimitForPaths_AppliesOnlyToConfiguredPaths(t *testing.T) {
router.IPExtractor = echo.ExtractIPDirect()
router.Use(PerIPRateLimitForPaths([]string{"/limited"}, 60, 1))
- router.POST("/limited", func(c echo.Context) error {
+ router.POST("/limited", func(c *echo.Context) error {
return c.NoContent(http.StatusOK)
})
- router.POST("/unlimited", func(c echo.Context) error {
+ router.POST("/unlimited", func(c *echo.Context) error {
return c.NoContent(http.StatusOK)
})
@@ -101,7 +101,7 @@ func TestPerIPRateLimitForPaths_TracksDistinctIPs(t *testing.T) {
router.IPExtractor = echo.ExtractIPDirect()
router.Use(PerIPRateLimitForPaths([]string{"/limited"}, 60, 1))
- router.POST("/limited", func(c echo.Context) error {
+ router.POST("/limited", func(c *echo.Context) error {
return c.NoContent(http.StatusOK)
})
@@ -123,8 +123,8 @@ func TestPerIPRateLimitForPaths_IndependentBucketPerPath(t *testing.T) {
router.IPExtractor = echo.ExtractIPDirect()
router.Use(PerIPRateLimitForPaths([]string{"/a", "/b"}, 60, 1))
- router.POST("/a", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
- router.POST("/b", func(c echo.Context) error { return c.NoContent(http.StatusOK) })
+ router.POST("/a", func(c *echo.Context) error { return c.NoContent(http.StatusOK) })
+ router.POST("/b", func(c *echo.Context) error { return c.NoContent(http.StatusOK) })
doReq := func(path string) int {
req := httptest.NewRequest(http.MethodPost, path, nil)
@@ -146,7 +146,7 @@ func TestPerIPRateLimitForPaths_RouteParamsDoNotEscapeFilter(t *testing.T) {
router.IPExtractor = echo.ExtractIPDirect()
router.Use(PerIPRateLimitForPaths([]string{"/webhooks/trigger/:token"}, 60, 1))
- router.POST("/webhooks/trigger/:token", func(c echo.Context) error {
+ router.POST("/webhooks/trigger/:token", func(c *echo.Context) error {
return c.NoContent(http.StatusOK)
})
diff --git a/backend/pkg/libarcane/edge/client_test.go b/backend/pkg/libarcane/edge/client_test.go
index 03dfd260c..454e185bb 100644
--- a/backend/pkg/libarcane/edge/client_test.go
+++ b/backend/pkg/libarcane/edge/client_test.go
@@ -22,8 +22,8 @@ import (
tunnelpb "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge/proto/tunnel/v1"
httputil "github.com/getarcaneapp/arcane/backend/v2/pkg/utils/httpx"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
- slogecho "github.com/samber/slog-echo"
+ "github.com/labstack/echo/v5"
+ slogecho "github.com/samber/slog-echo/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/http2"
@@ -1273,7 +1273,7 @@ func TestTunnelClient_GRPC_WebSocketProxyEndToEnd(t *testing.T) {
}, 5*time.Second, 20*time.Millisecond)
router := echo.New()
- router.GET("/proxy-ws", func(c echo.Context) error {
+ router.GET("/proxy-ws", func(c *echo.Context) error {
tunnel, ok := GetRegistry().Get(envID).Get()
if !ok || tunnel == nil {
return c.NoContent(http.StatusServiceUnavailable)
@@ -2136,7 +2136,7 @@ func TestTunnelClient_InternalRequestSkipsSlogEcho(t *testing.T) {
router := echo.New()
router.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
- return func(c echo.Context) error {
+ return func(c *echo.Context) error {
if IsInternalTunnelRequest(c.Request().Context()) {
sawInternalTunnelRequest = true
return next(c)
@@ -2144,7 +2144,7 @@ func TestTunnelClient_InternalRequestSkipsSlogEcho(t *testing.T) {
return loggerMiddleware(next)(c)
}
})
- router.GET("/local/api", func(c echo.Context) error {
+ router.GET("/local/api", func(c *echo.Context) error {
return c.String(http.StatusOK, "local response")
})
diff --git a/backend/pkg/libarcane/edge/poll_control.go b/backend/pkg/libarcane/edge/poll_control.go
index df55794f9..4cfe4bb89 100644
--- a/backend/pkg/libarcane/edge/poll_control.go
+++ b/backend/pkg/libarcane/edge/poll_control.go
@@ -13,7 +13,7 @@ import (
"emperror.dev/errors"
"github.com/getarcaneapp/arcane/backend/v2/pkg/remenv"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
const (
@@ -188,7 +188,7 @@ func (r *PollRuntimeRegistry) Get(envID string, now time.Time) mo.Option[PollRun
return mo.Some(state)
}
-func decodeTunnelPollRequestInternal(c echo.Context) (*TunnelPollRequest, error) {
+func decodeTunnelPollRequestInternal(c *echo.Context) (*TunnelPollRequest, error) {
if c == nil || c.Request() == nil || c.Request().Body == nil {
return &TunnelPollRequest{}, nil
}
@@ -234,7 +234,7 @@ func (s *TunnelServer) pollStatusInternal(envID string) TunnelPollResponse {
}
// HandlePoll is the HTTP control-plane endpoint used by poll-mode agents.
-func (s *TunnelServer) HandlePoll(c echo.Context) error {
+func (s *TunnelServer) HandlePoll(c *echo.Context) error {
req := c.Request()
ctx := req.Context()
diff --git a/backend/pkg/libarcane/edge/poll_control_test.go b/backend/pkg/libarcane/edge/poll_control_test.go
index f76d2bce1..93d2a58fa 100644
--- a/backend/pkg/libarcane/edge/poll_control_test.go
+++ b/backend/pkg/libarcane/edge/poll_control_test.go
@@ -10,7 +10,7 @@ import (
"testing"
"time"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
diff --git a/backend/pkg/libarcane/edge/proxy.go b/backend/pkg/libarcane/edge/proxy.go
index 33cd658c3..913d68ef7 100644
--- a/backend/pkg/libarcane/edge/proxy.go
+++ b/backend/pkg/libarcane/edge/proxy.go
@@ -12,7 +12,7 @@ import (
"emperror.dev/errors"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
const (
@@ -193,7 +193,7 @@ func (s *grpcResponseState) handleCommandComplete(incoming *TunnelMessage) (int,
}
// ProxyHTTPRequest is a helper that proxies an echo context through a tunnel
-func ProxyHTTPRequest(c echo.Context, tunnel *AgentTunnel, targetPath string) error {
+func ProxyHTTPRequest(c *echo.Context, tunnel *AgentTunnel, targetPath string) error {
req := c.Request()
ctx := req.Context()
diff --git a/backend/pkg/libarcane/edge/proxy_test.go b/backend/pkg/libarcane/edge/proxy_test.go
index bfc0958e2..556e171dd 100644
--- a/backend/pkg/libarcane/edge/proxy_test.go
+++ b/backend/pkg/libarcane/edge/proxy_test.go
@@ -14,7 +14,7 @@ import (
tunnelpb "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge/proto/tunnel/v1"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
diff --git a/backend/pkg/libarcane/edge/remenv.go b/backend/pkg/libarcane/edge/remenv.go
index cf087d14b..b0cfd6777 100644
--- a/backend/pkg/libarcane/edge/remenv.go
+++ b/backend/pkg/libarcane/edge/remenv.go
@@ -6,7 +6,7 @@ import (
"strings"
"github.com/getarcaneapp/arcane/backend/v2/pkg/remenv"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
const (
@@ -32,7 +32,7 @@ func CopyRequestHeaders(from http.Header, to http.Header, skip map[string]struct
}
}
-func SetAuthHeader(req *http.Request, c echo.Context) {
+func SetAuthHeader(req *http.Request, c *echo.Context) {
// Forward API key header if present
if apiKey := c.Request().Header.Get(HeaderAPIKey); apiKey != "" {
req.Header.Set(HeaderAPIKey, apiKey)
@@ -52,7 +52,7 @@ func SetAgentToken(req *http.Request, accessToken *string) {
// BuildWebSocketHeaders constructs a header set for proxying WebSocket requests
// to a remote environment, forwarding authentication in the same way as HTTP proxying.
-func BuildWebSocketHeaders(c echo.Context, accessToken *string) http.Header {
+func BuildWebSocketHeaders(c *echo.Context, accessToken *string) http.Header {
headers := http.Header{}
req := c.Request()
diff --git a/backend/pkg/libarcane/edge/remenv_test.go b/backend/pkg/libarcane/edge/remenv_test.go
index 1b9868031..bdd16d15e 100644
--- a/backend/pkg/libarcane/edge/remenv_test.go
+++ b/backend/pkg/libarcane/edge/remenv_test.go
@@ -14,7 +14,7 @@ import (
tunnelpb "github.com/getarcaneapp/arcane/backend/v2/pkg/libarcane/edge/proto/tunnel/v1"
"github.com/getarcaneapp/arcane/backend/v2/pkg/remenv"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc"
diff --git a/backend/pkg/libarcane/edge/server.go b/backend/pkg/libarcane/edge/server.go
index 429414f19..07ad5d882 100644
--- a/backend/pkg/libarcane/edge/server.go
+++ b/backend/pkg/libarcane/edge/server.go
@@ -16,7 +16,7 @@ import (
"github.com/getarcaneapp/arcane/backend/v2/pkg/remenv"
"github.com/google/uuid"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/samber/mo"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@@ -124,13 +124,13 @@ func (s *TunnelServer) SetConfig(cfg *Config) {
// HandleConnect is the WebSocket handler for edge agent connections.
// This is registered at /api/tunnel/connect.
-func (s *TunnelServer) HandleConnect(c echo.Context) error {
+func (s *TunnelServer) HandleConnect(c *echo.Context) error {
req := c.Request()
ctx := req.Context()
callbackCtx := context.WithoutCancel(ctx)
// Upgrade to WebSocket.
- conn, err := tunnelUpgrader.Upgrade(c.Response().Writer, req, nil)
+ conn, err := tunnelUpgrader.Upgrade(c.Response(), req, nil)
if err != nil {
slog.ErrorContext(ctx, "Failed to upgrade edge tunnel connection", "error", err)
return nil
@@ -187,7 +187,7 @@ func (s *TunnelServer) HandleConnect(c echo.Context) error {
// HandleMTLSEnroll returns manager-generated edge client certificates for the
// calling environment when generated edge mTLS is enabled. The response includes
// private key material, so response-body logging must not be enabled here.
-func (s *TunnelServer) HandleMTLSEnroll(c echo.Context) error {
+func (s *TunnelServer) HandleMTLSEnroll(c *echo.Context) error {
req := c.Request()
ctx := req.Context()
c.Response().Header().Set("Cache-Control", "no-store")
diff --git a/backend/pkg/libarcane/edge/server_test.go b/backend/pkg/libarcane/edge/server_test.go
index 5e00a3fb2..b8da880cb 100644
--- a/backend/pkg/libarcane/edge/server_test.go
+++ b/backend/pkg/libarcane/edge/server_test.go
@@ -15,7 +15,7 @@ import (
"time"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/grpc/codes"
diff --git a/backend/pkg/libarcane/edge/ws_proxy.go b/backend/pkg/libarcane/edge/ws_proxy.go
index 4dfb76375..807d46b8d 100644
--- a/backend/pkg/libarcane/edge/ws_proxy.go
+++ b/backend/pkg/libarcane/edge/ws_proxy.go
@@ -8,7 +8,7 @@ import (
"github.com/google/uuid"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
)
const (
@@ -32,11 +32,11 @@ var wsUpgraderForProxy = websocket.Upgrader{
// ProxyWebSocketRequest proxies a WebSocket upgrade through an edge tunnel.
// This handles logs, stats, and other streaming endpoints.
-func ProxyWebSocketRequest(c echo.Context, tunnel *AgentTunnel, targetPath string) error {
+func ProxyWebSocketRequest(c *echo.Context, tunnel *AgentTunnel, targetPath string) error {
req := c.Request()
ctx := req.Context()
- clientWS, err := wsUpgraderForProxy.Upgrade(c.Response().Writer, req, nil)
+ clientWS, err := wsUpgraderForProxy.Upgrade(c.Response(), req, nil)
if err != nil {
slog.ErrorContext(ctx, "Failed to upgrade WebSocket for edge proxy", "error", err)
return nil
diff --git a/backend/pkg/libarcane/edge/ws_proxy_test.go b/backend/pkg/libarcane/edge/ws_proxy_test.go
index d3e077197..d64e4cfef 100644
--- a/backend/pkg/libarcane/edge/ws_proxy_test.go
+++ b/backend/pkg/libarcane/edge/ws_proxy_test.go
@@ -9,7 +9,7 @@ import (
"time"
"github.com/gorilla/websocket"
- "github.com/labstack/echo/v4"
+ "github.com/labstack/echo/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@@ -92,7 +92,7 @@ func TestProxyWebSocketRequest(t *testing.T) {
// Setup Manager
router := echo.New()
- router.GET("/proxy-ws", func(c echo.Context) error {
+ router.GET("/proxy-ws", func(c *echo.Context) error {
return ProxyWebSocketRequest(c, tunnel, "/api/environments/0/ws/system/stats")
})
@@ -159,7 +159,7 @@ func TestProxyWebSocketRequest_ClientClose(t *testing.T) {
}()
router := echo.New()
- router.GET("/proxy-ws", func(c echo.Context) error {
+ router.GET("/proxy-ws", func(c *echo.Context) error {
return ProxyWebSocketRequest(c, tunnel, "/api/environments/0/ws/system/stats")
})
proxyServer := httptest.NewServer(router)
diff --git a/go.work.sum b/go.work.sum
index 950729ac3..e6200c647 100644
--- a/go.work.sum
+++ b/go.work.sum
@@ -310,8 +310,6 @@ cyphar.com/go-pathrs v0.2.1 h1:9nx1vOgwVvX1mNBWDu93+vaceedpbsDqo+XuBGL40b8=
cyphar.com/go-pathrs v0.2.1/go.mod h1:y8f1EMG7r+hCuFf/rXsKqMJrJAUoADZGNh5/vZPKcGc=
cyphar.com/go-pathrs v0.2.4 h1:iD/mge36swa1UFKdINkr1Frkpp6wZsy3YYEildj9cLY=
cyphar.com/go-pathrs v0.2.4/go.mod h1:y8f1EMG7r+hCuFf/rXsKqMJrJAUoADZGNh5/vZPKcGc=
-emperror.dev/emperror v0.33.0/go.mod h1:CeOIKPcppTE8wn+3xBNcdzdHMMIP77sLOHS0Ik56m+w=
-emperror.dev/errors v0.8.0/go.mod h1:YcRvLPh626Ubn2xqtoprejnA5nFha+TJ+2vew48kWuE=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/edwards25519 v1.2.0 h1:crnVqOiS4jqYleHd9vaKZ+HKtHfllngJIiOpNpoJsjo=
@@ -669,6 +667,7 @@ github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM
github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4=
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
+github.com/bytedance/sonic v1.15.1/go.mod h1:mT2NbXunuaEbnZ+mRIX/vYqKISmgEuHFDI4UzmKx2SA=
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
github.com/bytedance/sonic/loader v0.5.1 h1:Ygpfa9zwRCCKSlrp5bBP/b/Xzc3VxsAW+5NIYXrOOpI=
@@ -738,6 +737,7 @@ github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58 h1:F1EaeKL/ta07PY
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
+github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU=
@@ -858,8 +858,10 @@ github.com/danielgtaylor/huma/v2 v2.35.0 h1:FRg3FgVKcMogVhbNY7FjyTwk+p/orLBR3hQB
github.com/danielgtaylor/huma/v2 v2.35.0/go.mod h1:3elp5brzdyyZsPlDVvf6w8RLnklKp3abolr+5op3fP0=
github.com/danielgtaylor/mexpr v1.9.1 h1:nA9bsGRmNlJeVCPFgGf7WhrLuKag/+iWfOaJ03iKFPI=
github.com/danielgtaylor/mexpr v1.9.1/go.mod h1:kAivYNRnBeE/IJinqBvVFvLrX54xX//9zFYwADo4Bc8=
+github.com/danielgtaylor/mexpr v1.10.1/go.mod h1:kAivYNRnBeE/IJinqBvVFvLrX54xX//9zFYwADo4Bc8=
github.com/danielgtaylor/shorthand/v2 v2.2.0 h1:hVsemdRq6v3JocP6YRTfu9rOoghZI9PFmkngdKqzAVQ=
github.com/danielgtaylor/shorthand/v2 v2.2.0/go.mod h1:t5QfaNf7DPru9ZLIIhPQSO7Gyvajm3euw7LxB/MTUqE=
+github.com/danielgtaylor/shorthand/v2 v2.4.0/go.mod h1:+JG16ZY99pciTkGphx18ruwefahdwHCv/jmllgUGKSM=
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
github.com/data-accelerator/zdfs v0.1.5 h1:F7td8AwicTZ3t618SsEYr8CMyMcxBE1KjkoyYO4T2GI=
@@ -979,6 +981,7 @@ github.com/fullstorydev/grpcurl v1.9.3/go.mod h1:/b4Wxe8bG6ndAjlfSUjwseQReUDUvBJ
github.com/fxamacker/cbor/v2 v2.5.0/go.mod h1:TA1xS00nchWmaBnEIxPSE5oHLuJBAVvqrtAnWBwBCVo=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
+github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/gabriel-vasile/mimetype v1.4.13 h1:46nXokslUBsAJE/wMsp5gtO500a4F3Nkz9Ufpk2AcUM=
github.com/gabriel-vasile/mimetype v1.4.13/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
github.com/getarcaneapp/arcane/types v0.0.0-20251219045603-8a9960a2bf04/go.mod h1:7Wj+0JnpYq4RQS+otyM6e4zkyJKDC01wxkWPyFCHwZA=
@@ -1097,10 +1100,12 @@ github.com/gofiber/fiber/v2 v2.52.13 h1:TOKP64iqC9b5P49VrBW5tHhUOvDyrtJ0xePEfzJb
github.com/gofiber/fiber/v2 v2.52.13/go.mod h1:YEcBbO/FB+5M1IZNBP9FO3J9281zgPAreiI1oqg8nDw=
github.com/gofiber/fiber/v3 v3.2.0 h1:g9+09D320foINPpCnR3ibQ5oBEFHjAWRRfDG1te54u8=
github.com/gofiber/fiber/v3 v3.2.0/go.mod h1:FHOsc2Db7HhHpsE62QAaJlXVV1pNkbZEptZ4jtti7m4=
+github.com/gofiber/fiber/v3 v3.3.0/go.mod h1:YH7/TAoRaU4kF8slDCtQuFJ1NzC+3MtxUI4KfvQtaIA=
github.com/gofiber/schema v1.7.1 h1:oSJBKdgP8JeIME4TQSAqlNKTU2iBB+2RNmKi8Nsc+TI=
github.com/gofiber/schema v1.7.1/go.mod h1:A/X5Ffyru4p9eBdp99qu+nzviHzQiZ7odLT+TwxWhbk=
github.com/gofiber/utils/v2 v2.0.4 h1:WwAxUA7L4MW2DjdEHF234lfqvBqd2vYYuBtA9TJq2ec=
github.com/gofiber/utils/v2 v2.0.4/go.mod h1:GGERKU3Vhj5z6hS8YKvxL99A54DjOvTFZ0cjZnG4Lj4=
+github.com/gofiber/utils/v2 v2.0.6/go.mod h1:p7mAHAk3+oUK10ZX2xTw9fZQixb4hCg8SKd4IH2xroU=
github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0=
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -1743,6 +1748,7 @@ github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
+github.com/quic-go/quic-go v0.59.1/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20250401214520-65e299d6c5c9 h1:bsUq1dX0N8AOIL7EB/X911+m4EHsnWEHeJ0c+3TTBrg=
@@ -1937,6 +1943,7 @@ github.com/valyala/fasthttp v1.69.0 h1:fNLLESD2SooWeh2cidsuFtOcrEi4uB4m1mPrkJMZy
github.com/valyala/fasthttp v1.69.0/go.mod h1:4wA4PfAraPlAsJ5jMSqCE2ug5tqUPwKXxVj8oNECGcw=
github.com/valyala/fasthttp v1.70.0 h1:LAhMGcWk13QZWm85+eg8ZBNbrq5mnkWFGbHMUJHIdXA=
github.com/valyala/fasthttp v1.70.0/go.mod h1:oDZEHHkJ/Buyklg6uURmYs19442zFSnCIfX3j1FY3pE=
+github.com/valyala/fasthttp v1.71.0/go.mod h1:z1sDUvOShhXq/C9mwH/fSm1Vb71tUJwmQdgkBrBNwnA=
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
github.com/vbatts/tar-split v0.11.5/go.mod h1:yZbwRsSeGjusneWgA781EKej9HF8vme8okylkAeNKLk=
@@ -2088,6 +2095,7 @@ go.mongodb.org/mongo-driver v1.17.6 h1:87JUG1wZfWsr6rIz3ZmpH90rL5tea7O3IHuSwHUps
go.mongodb.org/mongo-driver v1.17.6/go.mod h1:Hy04i7O2kC4RS06ZrhPRqj/u4DTYkFDAAccj+rVKqgQ=
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
+go.mongodb.org/mongo-driver/v2 v2.6.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/contrib/detectors/gcp v1.38.0 h1:ZoYbqX7OaA/TAikspPl3ozPI6iY6LiIY9I8cUfm+pJs=
go.opentelemetry.io/contrib/detectors/gcp v1.38.0/go.mod h1:SU+iU7nu5ud4oCb3LQOhIZ3nRLj6FNVrKgtflbaf2ts=
@@ -2199,6 +2207,7 @@ golang.org/x/arch v0.24.0 h1:qlJ3M9upxvFfwRM51tTg3Yl+8CP9vCC1E7vlFpgv99Y=
golang.org/x/arch v0.24.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
golang.org/x/arch v0.25.0 h1:qnk6Ksugpi5Bz32947rkUgDt9/s5qvqDPl/gBKdMJLE=
golang.org/x/arch v0.25.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8=
+golang.org/x/arch v0.27.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=