fix(gateway/config): coerce quoted boolean values in config parsing - #15334
Closed
Yukipukii1 wants to merge 1 commit into
Closed
fix(gateway/config): coerce quoted boolean values in config parsing#15334Yukipukii1 wants to merge 1 commit into
Yukipukii1 wants to merge 1 commit into
Conversation
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! |
1 task
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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