From f5dbc718a76bafe5c674a89bbe39111ebca62f45 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 24 Jan 2024 09:10:16 +0400 Subject: [PATCH] fix: accept agent RPC connection without version query parameter (#11790) Fixes an issue where Coder v2.7.1 agents connect to /api/v2/workspaceagents/me/rpc without a version query parameter --- coderd/workspaceagentsrpc.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coderd/workspaceagentsrpc.go b/coderd/workspaceagentsrpc.go index dd89f07460..a0bb039d1f 100644 --- a/coderd/workspaceagentsrpc.go +++ b/coderd/workspaceagentsrpc.go @@ -40,10 +40,10 @@ func (api *API) workspaceAgentRPC(rw http.ResponseWriter, r *http.Request) { version := r.URL.Query().Get("version") if version == "" { - httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{ - Message: "Missing required query parameter: version", - }) - return + // The initial version on this HTTP endpoint was 2.0, so assume this version if unspecified. + // Coder v2.7.1 (not to be confused with the Agent API version) calls this endpoint without + // a version parameter and wants Agent API version 2.0. + version = "2.0" } if err := proto.CurrentVersion.Validate(version); err != nil { httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{