Skip to content

fix: Handle explicit null values in SessionResetPolicy config (#1119) - #1139

Closed
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/session-reset-policy-null-values-1119
Closed

Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/session-reset-policy-null-values-1119

Conversation

@Bartok9

@Bartok9 Bartok9 commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Summary

When users explicitly set at_hour or idle_minutes to null in their config.yaml, the gateway previously failed with a TypeError. This PR fixes that by properly handling null values in SessionResetPolicy.from_dict().

Problem

Python's dict.get() only returns the default value when a key is missing, not when the key exists with a None/null value:

default_reset_policy:
  mode: both
  at_hour: null      # This causes TypeError
  idle_minutes: null # This too

Solution

Explicitly check for None values before applying defaults:

at_hour = data.get("at_hour")
if at_hour is None:
    at_hour = 4

Changes

  • gateway/config.py: Update SessionResetPolicy.from_dict() to handle null values
  • tests/gateway/test_config.py: Add regression tests for null value handling

Testing

All existing tests pass, plus new tests for:

  • Explicit null values → use defaults
  • Partial null values → defaults for null, preserve set values
  • Empty dict → all defaults

Fixes #1119

…search#1119)

When users explicitly set at_hour or idle_minutes to null in config.yaml,
the from_dict() method now correctly applies default values.

Python's dict.get() only returns defaults when keys are missing, not when
keys exist with None/null values. This caused TypeError when comparing
None with integers during validation.

Changes:
- Update SessionResetPolicy.from_dict() to explicitly check for None values
- Add comprehensive tests for null value handling

Fixes NousResearch#1119
@Bartok9

Bartok9 commented Mar 14, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #1194, which merged the same null handling fix along with the API timeout feature. Thanks!

@Bartok9 Bartok9 closed this Mar 14, 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

1 participant