fix(gateway): handle explicit null values in SessionResetPolicy config#1148
Closed
eren-karakus0 wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix(gateway): handle explicit null values in SessionResetPolicy config#1148eren-karakus0 wants to merge 1 commit intoNousResearch:mainfrom
eren-karakus0 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
dict.get("key", default) returns None when the key exists with a null
value, bypassing the default parameter. This causes a TypeError when
comparing None with integers in the validation logic.
Fixes NousResearch#1119
Contributor
|
Thanks for the contribution! This fix is already on main — the null-coalescing for |
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
TypeErrorwhen users setat_houroridle_minutestonullin theirconfig.yaml.dict.get("key", default)only returns the default when the key is missing, not when it exists with aNonevalue. This causedNoneto reach the validation logic (0 <= None <= 23), raising aTypeErrorand crashing the gateway on startup.Changes
gateway/config.py: Replacedata.get("at_hour", 4)pattern with explicitNonechecks inSessionResetPolicy.from_dict()tests/gateway/test_config.py: Add 3 test cases — explicit null values, missing keys, partial nullTest plan
nullfor bothat_hourandidle_minutes→ defaults appliednull, the other valid → only null field gets defaultFixes #1119