fix(gateway): harden malformed env port overrides - #20205
Closed
Frowtek wants to merge 1 commit into
Closed
Conversation
Closed
2 tasks
Contributor
|
Thanks for identifying this malformed-environment startup failure mode. The requested behavior is already present on current
Automated hermes-sweeper review. |
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.
What does this PR do?
This PR fixes a gateway config parsing bug where malformed environment values for
BLUEBUBBLES_WEBHOOK_PORTorWECOM_CALLBACK_PORTcould crash_apply_env_overrides()with aValueError.gateway/config.pyalready has_coerce_int()for defensive numeric parsing, but these two env override paths were still using rawint(...). This change switches them to_coerce_int(..., 8645)so invalid values fall back to the documented default port instead of crashing gateway startup or config loading.Related Issue
No linked issue; found via code inspection.
Type of Change
Changes Made
gateway/config.pyto use_coerce_int()forWECOM_CALLBACK_PORTandBLUEBUBBLES_WEBHOOK_PORTtests/gateway/test_config.pycovering malformed env values for both portsHow to Test
Before the fix, set either:
BLUEBUBBLES_SERVER_URL=http://localhost:1234BLUEBUBBLES_PASSWORD=secretBLUEBUBBLES_WEBHOOK_PORT=not-a-portor:
WECOM_CALLBACK_CORP_ID=corp-idWECOM_CALLBACK_CORP_SECRET=corp-secretWECOM_CALLBACK_PORT=not-a-portCall
_apply_env_overrides(GatewayConfig())or load gateway config. Before the fix, it raisesValueError. After the fix, it falls back to8645.Run:
pytest tests/gateway/test_config.py -k MalformedEnvPortOverrides -qpytest tests/gateway/test_config.py -qChecklist