From 5813b43f6bdaa388d7f84085a16450cba265a5cd Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Tue, 11 Aug 2026 11:51:58 -0400 Subject: [PATCH] Drop unused mongodb:// branch from endpoint host extraction --- src/Platform/Hosted/Components/ConnectExplorer.tsx | 5 +++-- .../Hosted/Helpers/ConnectionStringParser.ts | 4 +--- src/Platform/Hosted/HostedUtils.ts | 13 ++----------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/Platform/Hosted/Components/ConnectExplorer.tsx b/src/Platform/Hosted/Components/ConnectExplorer.tsx index 46fcd89bf..c9fa6db4a 100644 --- a/src/Platform/Hosted/Components/ConnectExplorer.tsx +++ b/src/Platform/Hosted/Components/ConnectExplorer.tsx @@ -64,8 +64,9 @@ export const validateDirectConnectionStringConnectivity = async ( return t(Keys.connectExplorer.errors.connectivityInvalid); } - // Configure the client the same way the Data Explorer will, then issue a lightweight authenticated - // request. The Cosmos client signs locally with the master key and routes through the same proxy. + // The Cosmos client reads its connection settings from userContext, so write the master key and + // endpoint there. Then we issue a lightweight authenticated read to confirm the + // credentials work. updateUserContext({ authType: AuthType.ConnectionString, masterKey, diff --git a/src/Platform/Hosted/Helpers/ConnectionStringParser.ts b/src/Platform/Hosted/Helpers/ConnectionStringParser.ts index 74421a8ee..e8270b868 100644 --- a/src/Platform/Hosted/Helpers/ConnectionStringParser.ts +++ b/src/Platform/Hosted/Helpers/ConnectionStringParser.ts @@ -45,9 +45,7 @@ export function parseConnectionString(connectionString: string): AccessInputMeta } // For the APIs that log in directly through the Cosmos client (SQL, Tables, Gremlin), derive the - // endpoints client-side instead of Portal Backend's accessinputmetadata call. Tables - // connection strings only carry the table endpoint, so the document endpoint is always constructed - // from the account name. Gremlin also needs its graph endpoint for websocket queries. + // endpoints client-side instead of Portal Backend's accessinputmetadata call. if (accessInput.accountName) { if ( accessInput.apiKind === ApiKind.SQL || diff --git a/src/Platform/Hosted/HostedUtils.ts b/src/Platform/Hosted/HostedUtils.ts index 1e3675a0e..fc9e21ecb 100644 --- a/src/Platform/Hosted/HostedUtils.ts +++ b/src/Platform/Hosted/HostedUtils.ts @@ -55,8 +55,7 @@ export function extractAccountKeyFromConnectionString(connectionString: string): } // SQL, Tables, and Gremlin can sign data-plane requests client-side with the account key, so they do -// not need the Portal Backend proxy for connection-string login. Mongo and Cassandra still require the -// proxy because they use wire protocols the browser cannot speak directly. +// not need the Portal Backend proxy for connection-string login. Mongo and Cassandra still require the proxy. export function isDirectConnectionStringLoginApi(apiKind: ApiKind): boolean { return apiKind === ApiKind.SQL || apiKind === ApiKind.Table || apiKind === ApiKind.Graph; } @@ -86,19 +85,11 @@ function extractHostToken(value: string, startIndex: number): string { } // Extracts the endpoint host from a connection string, mirroring ExtractEndpointHost in the Portal -// Backend. Handles AccountEndpoint/TableEndpoint (URI or bare host), HostName, and mongodb:// segments. +// Backend. Handles AccountEndpoint/TableEndpoint (URI or bare host) and HostName. export function extractEndpointHostFromConnectionString(connectionString: string): string | undefined { for (const part of connectionString.split(";")) { const trimmed = part.trim(); - if (trimmed.toLowerCase().startsWith("mongodb://")) { - const atIndex = trimmed.indexOf("@"); - if (atIndex >= 0 && atIndex < trimmed.length - 1) { - return extractHostToken(trimmed, atIndex + 1); - } - continue; - } - const equalsIndex = trimmed.indexOf("="); if (equalsIndex < 0 || equalsIndex === trimmed.length - 1) { continue;