From d18127503dd75b26dc6de6d4e55ae326193d3291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Sibiril?= <81782+aureliensibiril@users.noreply.github.com> Date: Wed, 22 Jul 2026 14:48:43 +0200 Subject: [PATCH] Pin Vercel OAuth callback team parameter name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Vercel connector reads the team from the camelCase teamId callback parameter, unlike the snake_case params most providers use. Nothing guarded the name, so a regression back to team_id would silently drop the team on every Vercel connect and leave the source resolving no users. Extract the read into vercelCallbackTeamID and pin the exact parameter name with a test, since the surrounding handler needs a live connector registry and database to exercise directly. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com> --- pkg/server/api/console/v1/resolver.go | 10 +++- pkg/server/api/console/v1/resolver_test.go | 69 ++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 pkg/server/api/console/v1/resolver_test.go diff --git a/pkg/server/api/console/v1/resolver.go b/pkg/server/api/console/v1/resolver.go index 7896448d2..79c99eb25 100644 --- a/pkg/server/api/console/v1/resolver.go +++ b/pkg/server/api/console/v1/resolver.go @@ -372,7 +372,7 @@ func handleConnectorComplete( // sent — fall back to /v2/user.id as a synthetic TeamID; the v3 // members endpoint accepts personal-account UIDs. if connectorProvider == coredata.ConnectorProviderVercel { - teamID := query.Get("teamId") + teamID := vercelCallbackTeamID(query) if teamID == "" { if oauth2Conn, ok := connection.(*connector.OAuth2Connection); ok && oauth2Conn.AccessToken != "" { if uid, err := connector.FetchVercelUserID(r.Context(), oauth2Conn.AccessToken); err == nil { @@ -476,6 +476,14 @@ func handleConnectorOAuth2Error( safeRedirect.Redirect(w, r, parsedURL.String(), "/", http.StatusSeeOther) } +// vercelCallbackTeamID returns the team identifier Vercel surfaces on the +// OAuth callback. Vercel uses the camelCase `teamId` query parameter (not the +// snake_case `team_id` most other params use); the name is pinned by a test so +// it cannot silently regress and leave every Vercel source without a team. +func vercelCallbackTeamID(query url.Values) string { + return query.Get("teamId") +} + // isValidPagerDutySubdomain reports whether s is a single DNS label // (RFC 1035 §2.3.1). PagerDuty subdomains are tenant identifiers that // will be embedded in API URLs; the OAuth callback is the only place diff --git a/pkg/server/api/console/v1/resolver_test.go b/pkg/server/api/console/v1/resolver_test.go new file mode 100644 index 000000000..76d1d8b82 --- /dev/null +++ b/pkg/server/api/console/v1/resolver_test.go @@ -0,0 +1,69 @@ +// Copyright (c) 2026 Probo Inc . +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package console_v1 + +import ( + "net/url" + "testing" + + "github.com/stretchr/testify/assert" +) + +// TestVercelCallbackTeamID pins the exact OAuth-callback query-parameter name +// Vercel uses. It is camelCase `teamId`; a regression to the snake_case +// `team_id` used by most other providers would silently drop the team on every +// Vercel connect and leave the source resolving nobody. +func TestVercelCallbackTeamID(t *testing.T) { + t.Parallel() + + cases := []struct { + name string + query url.Values + want string + }{ + { + name: "camelCase teamId is read", + query: url.Values{"teamId": {"team_abc123"}}, + want: "team_abc123", + }, + { + name: "snake_case team_id is ignored", + query: url.Values{"team_id": {"team_abc123"}}, + want: "", + }, + { + name: "absent parameter yields empty", + query: url.Values{}, + want: "", + }, + } + + for _, tc := range cases { + t.Run( + tc.name, + func(t *testing.T) { + t.Parallel() + + assert.Equal(t, tc.want, vercelCallbackTeamID(tc.query)) + }, + ) + } +}