From 3c2125f646c185cee57307fcfff8a456ef1afa3c Mon Sep 17 00:00:00 2001 From: Brainslug Date: Tue, 11 Oct 2022 22:47:33 +0200 Subject: [PATCH] public_url_file in .env causes server start error (#15898) * allow *_FILE environment vars to overwrite default values * added test * added mock for fs * removed test --- api/src/env.test.ts | 1 + api/src/env.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api/src/env.test.ts b/api/src/env.test.ts index c2ac9bbb57..e87ee47288 100644 --- a/api/src/env.test.ts +++ b/api/src/env.test.ts @@ -19,6 +19,7 @@ describe('env processed values', () => { afterEach(() => { process.env = originalEnv; + jest.resetAllMocks(); }); test('Number value should be a number', () => { diff --git a/api/src/env.ts b/api/src/env.ts index 4622a8fcb3..b237309e3c 100644 --- a/api/src/env.ts +++ b/api/src/env.ts @@ -401,7 +401,7 @@ function processValues(env: Record) { if (key.length > 5 && key.endsWith('_FILE')) { newKey = key.slice(0, -5); if (allowedEnvironmentVars.some((pattern) => pattern.test(newKey as string))) { - if (newKey in env) { + if (newKey in env && !(newKey in defaults && env[newKey] === defaults[newKey])) { throw new Error( `Duplicate environment variable encountered: you can't use "${newKey}" and "${key}" simultaneously.` );