Skip to content

fix(gateway): handle explicit null values in SessionResetPolicy config#1148

Closed
eren-karakus0 wants to merge 1 commit intoNousResearch:mainfrom
eren-karakus0:fix/session-reset-policy-null-values
Closed

fix(gateway): handle explicit null values in SessionResetPolicy config#1148
eren-karakus0 wants to merge 1 commit intoNousResearch:mainfrom
eren-karakus0:fix/session-reset-policy-null-values

Conversation

@eren-karakus0
Copy link
Contributor

Summary

Fixes TypeError when users set at_hour or idle_minutes to null in their config.yaml.

dict.get("key", default) only returns the default when the key is missing, not when it exists with a None value. This caused None to reach the validation logic (0 <= None <= 23), raising a TypeError and crashing the gateway on startup.

Changes

  • gateway/config.py: Replace data.get("at_hour", 4) pattern with explicit None checks in SessionResetPolicy.from_dict()
  • tests/gateway/test_config.py: Add 3 test cases — explicit null values, missing keys, partial null

Test plan

  • Explicit null for both at_hour and idle_minutes → defaults applied
  • Missing keys → defaults applied
  • One field null, the other valid → only null field gets default
  • Existing roundtrip test still passes

Fixes #1119

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
@teknium1
Copy link
Contributor

Thanks for the contribution! This fix is already on main — the null-coalescing for at_hour and idle_minutes was merged independently, and mode was fixed in #1488. There's also an existing test (test_from_dict_treats_null_values_as_defaults) covering the null-value case. Closing as redundant.

@teknium1 teknium1 closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Null Values in SessionResetPolicy Configuration Cause TypeError

2 participants