From 6819f144488874c2aaa6270a6d4f301208c88d93 Mon Sep 17 00:00:00 2001 From: Arvuno Date: Wed, 3 Jun 2026 19:54:35 +0000 Subject: [PATCH] feat(server): optional default for get_setting_value get_setting_value returns an empty string when a key is not found, which forces every call site to remember to treat '' as a sentinel and provide its own fallback. The fallback is sometimes a hard-coded default and sometimes a different code path entirely, leading to inconsistent handling across the codebase. Add an optional argument that defaults to '' (preserves the existing behaviour for every call site) and is returned when the key is not present. New call sites can opt into a more meaningful default without changing the function's signature for existing callers. Refs #1626. --- server/helper.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/helper.py b/server/helper.py index bfbf65c1b..59278b803 100755 --- a/server/helper.py +++ b/server/helper.py @@ -197,7 +197,7 @@ def get_setting(key): # ------------------------------------------------------------------------------- # Return setting value -def get_setting_value(key): +def get_setting_value(key, default=""): """ Retrieve a setting value from configuration. @@ -208,13 +208,16 @@ def get_setting_value(key): Args: key (str): The setting key to look up. + default (Any): Value to return when the key is not found. Defaults + to "" for backwards compatibility with call sites that already + treat an empty string as "missing". Returns: - Any: The Python-typed setting value, or an empty string if not found. + Any: The Python-typed setting value, or `default` if not found. """ - # Returns empty string if not found - value = "" + # Returns default if not found + value = default # lookup key in secondary cache if key in SETTINGS_SECONDARYCACHE: