From 428f8d1684c7e14262b4971887d5aa774b157980 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 6 Jun 2021 02:36:09 -0400 Subject: [PATCH] Settings: Deprecate null as the default default value --- CHANGELOG.md | 3 +++ settings.json.docker | 4 +++- settings.json.template | 4 +++- src/node/utils/Settings.js | 4 +++- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c50a3f6..5959858f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ `"${UNSET_VAR:undefined}"`), the setting is now removed instead of set to the string "undefined". It is no longer possible to produce the string "undefined" via environment variable substitution. + * Support for unset variables without a default value is now deprecated. + Please change all instances of `"${FOO}"` in your `settings.json` to + `${FOO:null}` to keep the current behavior. ### Notable enhancements diff --git a/settings.json.docker b/settings.json.docker index 80becd3b..426a5895 100644 --- a/settings.json.docker +++ b/settings.json.docker @@ -45,7 +45,9 @@ * - "${UNSET_VAR:undefined}" causes the setting to be removed (or be set * to null, if used as a member of an array). * - If the environment variable is unset and no default value is provided, - * the value becomes null. + * the value becomes null. THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF + * ETHERPAD; if you want the default value to be null, you should explicitly + * specify "null" as the default value. * * EXAMPLE: * "port": "${PORT:9001}" diff --git a/settings.json.template b/settings.json.template index 3469cc7a..2d7f119a 100644 --- a/settings.json.template +++ b/settings.json.template @@ -36,7 +36,9 @@ * - "${UNSET_VAR:undefined}" causes the setting to be removed (or be set * to null, if used as a member of an array). * - If the environment variable is unset and no default value is provided, - * the value becomes null. + * the value becomes null. THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF + * ETHERPAD; if you want the default value to be null, you should explicitly + * specify "null" as the default value. * * EXAMPLE: * "port": "${PORT:9001}" diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 27630a04..482abd73 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -599,7 +599,9 @@ const lookupEnvironmentVariables = (obj) => { if ((envVarValue === undefined) && (defaultValue === undefined)) { console.warn(`Environment variable "${envVarName}" does not contain any value for ` + - `configuration key "${key}", and no default was given. Returning null.`); + `configuration key "${key}", and no default was given. Using null. ` + + 'THIS BEHAVIOR MAY CHANGE IN A FUTURE VERSION OF ETHERPAD; you should ' + + 'explicitly use "null" as the default if you want to continue to use null.'); /* * We have to return null, because if we just returned undefined, the