From 7c1f54389187fcc4f07f61102c02ef383ced31fa Mon Sep 17 00:00:00 2001 From: Nate Date: Mon, 20 Jan 2025 22:17:02 -0800 Subject: [PATCH] fix e2e tests by not calling platform on local mode --- core/config/yaml/clientRender.ts | 9 +++- core/package-lock.json | 8 ++-- core/package.json | 2 +- extensions/vscode/package-lock.json | 2 +- gui/package-lock.json | 2 +- gui/src/components/markdown/FilenameLink.tsx | 2 +- packages/config-yaml/package.json | 2 +- packages/config-yaml/src/load/clientRender.ts | 47 ++++++++++--------- 8 files changed, 41 insertions(+), 33 deletions(-) diff --git a/core/config/yaml/clientRender.ts b/core/config/yaml/clientRender.ts index 1f9e2f98f..8cb727456 100644 --- a/core/config/yaml/clientRender.ts +++ b/core/config/yaml/clientRender.ts @@ -7,7 +7,7 @@ import { import { IDE } from "../.."; import { ControlPlaneClient } from "../../control-plane/client"; -export function clientRenderHelper( +export async function clientRenderHelper( unrolledAssistant: string, ide: IDE, controlPlaneClient: ControlPlaneClient, @@ -31,5 +31,10 @@ export function clientRenderHelper( resolveFQSNs: controlPlaneClient.resolveFQSNs.bind(controlPlaneClient), }; - return clientRender(unrolledAssistant, ideSecretStore, platformClient); + const userId = await controlPlaneClient.userId; + return await clientRender( + unrolledAssistant, + ideSecretStore, + userId ? platformClient : undefined, + ); } diff --git a/core/package-lock.json b/core/package-lock.json index 82e73913f..ec82ab0cd 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.15", + "@continuedev/config-yaml": "^1.0.16", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -3038,9 +3038,9 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.15", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.15.tgz", - "integrity": "sha512-00c1pz+FqAVEWLo8t71OJzm1KBAAJCXqIjd917Vy8lr7xO0Eoj42lo2GFlVRnqQ0hQvhFQ0s9onHhRag/phHZA==", + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.16.tgz", + "integrity": "sha512-r3dzTvL8aQ5RrzM+FX6fF+U12/crU4wpPXgDcDloSsxiOQfu3k/shLCbNzFPW57XhLUQAmUJYSZsJbIvYrNPNA==", "dependencies": { "@continuedev/config-types": "^1.0.14", "yaml": "^2.6.1", diff --git a/core/package.json b/core/package.json index 3f5391b28..477290c9b 100644 --- a/core/package.json +++ b/core/package.json @@ -46,7 +46,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.15", + "@continuedev/config-yaml": "^1.0.16", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index c85a40fe4..38d0db7c8 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.15", + "@continuedev/config-yaml": "^1.0.16", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/gui/package-lock.json b/gui/package-lock.json index 612acedbd..922ac8e10 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -108,7 +108,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.15", + "@continuedev/config-yaml": "^1.0.16", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/gui/src/components/markdown/FilenameLink.tsx b/gui/src/components/markdown/FilenameLink.tsx index 80a206a1d..baa0d3a90 100644 --- a/gui/src/components/markdown/FilenameLink.tsx +++ b/gui/src/components/markdown/FilenameLink.tsx @@ -31,7 +31,7 @@ function FilenameLink({ rif }: FilenameLinkProps) { ); relPathOrBasename = relativePathOrBasename; } catch (e) { - return getUriPathBasename(rif.filepath); + return {getUriPathBasename(rif.filepath)}; } return ( diff --git a/packages/config-yaml/package.json b/packages/config-yaml/package.json index 6fb90abbf..85474ad17 100644 --- a/packages/config-yaml/package.json +++ b/packages/config-yaml/package.json @@ -1,6 +1,6 @@ { "name": "@continuedev/config-yaml", - "version": "1.0.15", + "version": "1.0.16", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/packages/config-yaml/src/load/clientRender.ts b/packages/config-yaml/src/load/clientRender.ts index 52e89cbfc..cf9b6ba91 100644 --- a/packages/config-yaml/src/load/clientRender.ts +++ b/packages/config-yaml/src/load/clientRender.ts @@ -15,7 +15,7 @@ import { export async function clientRender( unrolledConfigContent: string, secretStore: SecretStore, - platformClient: PlatformClient, + platformClient?: PlatformClient, ): Promise { // 1. First we need to get a list of all the FQSNs that are required to render the config const secrets = getTemplateVariables(unrolledConfigContent); @@ -34,31 +34,34 @@ export async function clientRender( } } - // 3. For any secrets not found, we send the FQSNs to the Continue Platform at the `/ide/sync-secrets` endpoint. This endpoint replies for each of the FQSNs with the following information (`SecretResult`): `foundAt`: tells which secret store it was found in (this is “user”, “org”, “package” or null if not found anywhere). If it’s found in an org or a package, it tells us the `secretLocation`, which is either just an org slug, or is a full org/package slug. If it’s found in “user” secrets, we send back the `value`. Full definition of `SecretResult` at [2]. The method of resolving an FQSN to a `SecretResult` is detailed at [3] - const secretResults = await platformClient.resolveFQSNs(unresolvedFQSNs); + // Don't use platform client in local mode + if (platformClient) { + // 3. For any secrets not found, we send the FQSNs to the Continue Platform at the `/ide/sync-secrets` endpoint. This endpoint replies for each of the FQSNs with the following information (`SecretResult`): `foundAt`: tells which secret store it was found in (this is “user”, “org”, “package” or null if not found anywhere). If it’s found in an org or a package, it tells us the `secretLocation`, which is either just an org slug, or is a full org/package slug. If it’s found in “user” secrets, we send back the `value`. Full definition of `SecretResult` at [2]. The method of resolving an FQSN to a `SecretResult` is detailed at [3] + const secretResults = await platformClient.resolveFQSNs(unresolvedFQSNs); - // 4. (back to the client) Any “user” secrets that were returned back are added to the local secret store so we don’t have to request them again - for (const secretResult of secretResults) { - if (!secretResult) { - continue; - } + // 4. (back to the client) Any “user” secrets that were returned back are added to the local secret store so we don’t have to request them again + for (const secretResult of secretResults) { + if (!secretResult) { + continue; + } + + if (!secretResult.found) { + // When a secret isn't found anywhere, we keep it templated as just the secret name + // in case it can be found in the on-prem proxy's env + secretsTemplateData["secrets." + encodeFQSN(secretResult.fqsn)] = + `\${{ secrets.${secretResult.fqsn.secretName} }}`; + continue; + } + + if ("value" in secretResult) { + secretStore.set(secretResult.fqsn.secretName, secretResult.value); + } - if (!secretResult.found) { - // When a secret isn't found anywhere, we keep it templated as just the secret name - // in case it can be found in the on-prem proxy's env secretsTemplateData["secrets." + encodeFQSN(secretResult.fqsn)] = - `\${{ secrets.${secretResult.fqsn.secretName} }}`; - continue; + "value" in secretResult + ? secretResult.value + : `\${{ secrets.${encodeSecretLocation(secretResult.secretLocation)} }}`; } - - if ("value" in secretResult) { - secretStore.set(secretResult.fqsn.secretName, secretResult.value); - } - - secretsTemplateData["secrets." + encodeFQSN(secretResult.fqsn)] = - "value" in secretResult - ? secretResult.value - : `\${{ secrets.${encodeSecretLocation(secretResult.secretLocation)} }}`; } // 5. User secrets are rendered in place of the template variable. Others remain templated, but replaced with the specific location where they are to be found (`${{ secrets. }}` instead of `${{ secrets. }}`)