Skip to content

fix(gateway/config): coerce quoted boolean values in config parsing - #15334

Closed
Yukipukii1 wants to merge 1 commit into
NousResearch:mainfrom
Yukipukii1:fix/gateway-config-bool-coercion
Closed

fix(gateway/config): coerce quoted boolean values in config parsing#15334
Yukipukii1 wants to merge 1 commit into
NousResearch:mainfrom
Yukipukii1:fix/gateway-config-bool-coercion

Conversation

@Yukipukii1

Copy link
Copy Markdown
Contributor

Summary

Fixes an edge case where quoted boolean values (e.g. "false") in YAML/dict config were not being normalized correctly for three gateway config fields. Because bool("false") is True in Python, these fields could remain effectively enabled even when the user explicitly wrote "false" in their config.

Bug

Class: invalid bool / config edge-case
Broken behavior: Quoted YAML strings like "false" were treated as truthy for some gateway bool fields.
User impact: A config value written as "false" could still behave as enabled/true.
Affected fields:

PlatformConfig.enabled
SessionResetPolicy.notify
GatewayConfig.always_log_local

Root Cause

The _coerce_bool() helper already existed in gateway/config.py but was not being applied consistently across these three fields.

Fix

Apply the existing _coerce_bool() helper to the three affected fields. No refactor — just consistent use of the helper that was already in place.
Changes in gateway/config.py:

line 138 — SessionResetPolicy.notify now normalizes quoted bool values via _coerce_bool()
line 181 — PlatformConfig.enabled now parses quoted bool values correctly
line 438 — GatewayConfig.always_log_local now parses quoted bool values correctly

Repro

pythonPlatformConfig.from_dict({"enabled": "false"}).enabled # before: truthy, now: False
SessionResetPolicy.from_dict({"notify": "false"}).notify # before: truthy, now: False
GatewayConfig.from_dict({"always_log_local": "false"}).always_log_local # before: truthy, now: False

Tests

Added regression tests covering both the from_dict() path and the config.yaml bridge path in tests/gateway/test_config.py:

line 55 — PlatformConfig.from_dict({"enabled": "false"})
line 147 — SessionResetPolicy.from_dict({"notify": "false"})
line 193 — GatewayConfig.from_dict({"always_log_local": "false"})
line 253 — config.yaml → platforms.api_server.enabled: "false"
line 271 — config.yaml → session_reset.notify: "false"
line 287 — config.yaml → always_log_local: "false"

Result: 33 passed, 20 warnings in 3.37s

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels Apr 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #15387 — your commit was cherry-picked onto current main with your authorship preserved in git log. Thanks for the fix and the thorough repro + tests!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants