From 3d1946e31c3df26cb123a13b7064b941302123cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deluan=20Quint=C3=A3o?= Date: Wed, 19 Nov 2025 20:17:01 -0500 Subject: [PATCH] fix(plugins): avoid Chi RouteContext pollution by using http.NewRequest (#4713) Signed-off-by: Deluan --- plugins/host_subsonicapi.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/host_subsonicapi.go b/plugins/host_subsonicapi.go index d3008798a..937dd044f 100644 --- a/plugins/host_subsonicapi.go +++ b/plugins/host_subsonicapi.go @@ -93,8 +93,12 @@ func (s *subsonicAPIServiceImpl) Call(ctx context.Context, req *subsonicapi.Call RawQuery: query.Encode(), } - // Create HTTP request with internal authentication - httpReq, err := http.NewRequestWithContext(ctx, "GET", finalURL.String(), nil) + // Create HTTP request with a fresh context to avoid Chi RouteContext pollution. + // Using http.NewRequest (instead of http.NewRequestWithContext) ensures the internal + // SubsonicAPI call doesn't inherit routing information from the parent handler, + // which would cause Chi to invoke the wrong handler. Authentication context is + // explicitly added in the next step via request.WithInternalAuth. + httpReq, err := http.NewRequest("GET", finalURL.String(), nil) if err != nil { return &subsonicapi.CallResponse{ Error: fmt.Sprintf("failed to create HTTP request: %v", err),