Skip to content

Commit 8a26187

Browse files
authored
Merge pull request #14297 from OfficeDev/qinzhouxu/fix
fix: scoping fallback env variables
2 parents d8ef600 + d0fb259 commit 8a26187

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

packages/fx-core/src/component/configManager/lifecycle.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
} from "./interface";
2525
import { MissingEnvironmentVariablesError } from "../../error";
2626
import { setErrorContext } from "../../common/globalVars";
27+
import { AzureEnvironmentVariables, OpenAIEnvironmentVariables } from "../constants";
2728

2829
function resolveDriverDef(
2930
def: DriverDefinition,
@@ -101,7 +102,10 @@ export function resolveString(
101102
resolved.push(envVar);
102103
newVal = newVal.replace(matches[0], envVal);
103104
}
104-
} else if (envVar.includes("AZURE") || envVar.includes("OPENAI")) {
105+
} else if (
106+
OpenAIEnvironmentVariables.hasOwnProperty(envVar) ||
107+
AzureEnvironmentVariables.hasOwnProperty(envVar)
108+
) {
105109
if (envVal) {
106110
resolved.push(envVar);
107111
newVal = newVal.replace(matches[0], envVal);

packages/fx-core/src/component/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,9 @@ export const OpenAIEnvironmentVariables = {
130130
AZURE_OPENAI_EMBEDDING_DEPLOYMENT: "AZURE_OPENAI_EMBEDDING_DEPLOYMENT",
131131
AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME: "AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME",
132132
};
133+
134+
export const AzureEnvironmentVariables = {
135+
AZURE_SEARCH_KEY: "AZURE_SEARCH_KEY",
136+
SECRET_AZURE_SEARCH_KEY: "SECRET_AZURE_SEARCH_KEY",
137+
AZURE_SEARCH_ENDPOINT: "AZURE_SEARCH_ENDPOINT",
138+
};

packages/fx-core/src/component/driver/file/createOrUpdateEnvironmentFile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ const getGenericEnvVarConfig = (envKey: string): OpenAIEnvVarConfig => ({
238238
validation: getNonEmptyStringValidation(
239239
"driver.file.createOrUpdateEnvironmentFile.genericEnvVar.validation"
240240
),
241+
isPassword: envKey.toLowerCase().includes("key") || envKey.toLowerCase().includes("secret"),
241242
});
242243

243244
const envVarConfigs: OpenAIEnvVarConfig[] = [

0 commit comments

Comments
 (0)