diff --git a/src/dbos-executor.ts b/src/dbos-executor.ts index 1c1dcbf00..1b788fa0c 100644 --- a/src/dbos-executor.ts +++ b/src/dbos-executor.ts @@ -167,7 +167,11 @@ export class DBOSExecutor implements DBOSExecutorContext { // Set configured environment variables if (config.env) { for (const [key, value] of Object.entries(config.env)) { - process.env[key] = value; + if (typeof value === "string") { + process.env[key] = value; + } else { + console.warn(`Invalid value type for environment variable ${key}: ${typeof value}`); + } } } diff --git a/src/dbos-runtime/config.ts b/src/dbos-runtime/config.ts index d73289a44..cfcab7656 100644 --- a/src/dbos-runtime/config.ts +++ b/src/dbos-runtime/config.ts @@ -49,7 +49,7 @@ export interface ConfigFile { export function substituteEnvVars(content: string): string { const regex = /\${([^}]+)}/g; // Regex to match ${VAR_NAME} style placeholders return content.replace(regex, (_, g1: string) => { - return process.env[g1] || ""; // If the env variable is not set, return an empty string. + return process.env[g1] || '""'; // If the env variable is not set, return an empty string. }); } diff --git a/tests/dbos-runtime/config.test.ts b/tests/dbos-runtime/config.test.ts index 3e0400d78..1d8d5a876 100644 --- a/tests/dbos-runtime/config.test.ts +++ b/tests/dbos-runtime/config.test.ts @@ -196,12 +196,14 @@ describe("dbos-config", () => { app_db_name: 'some DB' env: FOOFOO: barbar + RANDENV: \${SOMERANDOMENV} `; jest.restoreAllMocks(); jest.spyOn(utils, "readFileSync").mockReturnValue(localMockDBOSConfigYamlString); const [dbosConfig, _dbosRuntimeConfig]: [DBOSConfig, DBOSRuntimeConfig] = parseConfigFile(mockCLIOptions); const dbosExec = new DBOSExecutor(dbosConfig); expect(process.env.FOOFOO).toBe("barbar"); + expect(process.env.RANDENV).toBe(""); // Empty string // We didn't init, so do some manual cleanup only clearInterval(dbosExec.flushBufferID); await dbosExec.telemetryCollector.destroy();