fix: allow env overrides to create missing config keys (#2064)

Previously, environment variable overrides (e.g. SYSTEM__INSTANCE_ID)
were silently skipped if the target key didn't already exist in
data/config.yaml. This caused SaaS pods running older LangBot images
(whose config template lacked system.instance_id) to ignore the
SYSTEM__INSTANCE_ID env var, falling back to a random UUID that
didn't match the pod UUID — breaking idle timeout tracking.

Now env overrides create missing keys (as strings) and missing
intermediate dicts, so they work regardless of template version.

Co-authored-by: rocksclawbot <rocksclawbot@users.noreply.github.com>
This commit is contained in:
Nody the lobster
2026-03-15 11:03:40 -04:00
committed by GitHub
parent 8bd6442965
commit 9e366fc536
+9 -3
View File
@@ -74,11 +74,12 @@ def _apply_env_overrides_to_config(cfg: dict) -> dict:
current = cfg current = cfg
for i, key in enumerate(keys): for i, key in enumerate(keys):
if not isinstance(current, dict) or key not in current: if not isinstance(current, dict):
break break
if i == len(keys) - 1: if i == len(keys) - 1:
# At the final key - check if it's a scalar value # At the final key
if key in current:
if isinstance(current[key], (dict, list)): if isinstance(current[key], (dict, list)):
# Skip dict and list types # Skip dict and list types
pass pass
@@ -87,7 +88,12 @@ def _apply_env_overrides_to_config(cfg: dict) -> dict:
converted_value = convert_value(env_value, current[key]) converted_value = convert_value(env_value, current[key])
current[key] = converted_value current[key] = converted_value
else: else:
# Navigate deeper # Key doesn't exist yet - create it as string
current[key] = env_value
else:
# Navigate deeper - create intermediate dict if needed
if key not in current:
current[key] = {}
current = current[key] current = current[key]
return cfg return cfg