Skip to content

fix(gateway): harden StreamingConfig bool and numeric coercion#16463

Merged
teknium1 merged 1 commit into
NousResearch:mainfrom
simbam99:fix/gateway-streaming-config-hardening
May 1, 2026
Merged

fix(gateway): harden StreamingConfig bool and numeric coercion#16463
teknium1 merged 1 commit into
NousResearch:mainfrom
simbam99:fix/gateway-streaming-config-hardening

Conversation

@simbam99
Copy link
Copy Markdown
Contributor

@simbam99 simbam99 commented Apr 27, 2026

What does this PR do?

This PR hardens gateway streaming config parsing so malformed or quoted config values do not silently change runtime behavior or crash config loading.

Before this change, gateway.config.StreamingConfig.from_dict() left enabled uncoerced and parsed numeric fields with direct float() / int() calls. That caused two concrete problems:

  1. streaming.enabled: "false" could remain truthy instead of disabling streaming.
  2. Invalid numeric values like edit_interval: "oops" could raise during config loading instead of falling back safely.

This approach is the right fix because it keeps the change narrowly scoped to the config parser, aligns StreamingConfig with the existing coercion patterns already used elsewhere in gateway config, and adds regression coverage for both failure modes.

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✅ Tests (adding or improving test coverage)

Changes Made

  • Updated gateway/config.py
  • Added safe numeric coercion helpers for float and int config fields
  • Changed StreamingConfig.from_dict() to:
    • coerce enabled via the existing bool-normalization path
    • safely parse edit_interval
    • safely parse buffer_threshold
    • safely parse fresh_final_after_seconds
  • Added regression tests in tests/gateway/test_config.py for:
    • quoted "false" on streaming.enabled
    • malformed numeric values falling back to defaults

How to Test

  1. Set a config value like streaming.enabled: "false" and verify it is treated as disabled instead of truthy.
  2. Set malformed numeric streaming config values such as edit_interval: "oops" and verify gateway config loading falls back to defaults instead of raising.
  3. Run:
    scripts/run_tests.sh tests/gateway/test_config.py
    

Expected result: 35 passed

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery area/config Config system, migrations, profiles labels Apr 27, 2026
@teknium1 teknium1 merged commit ccfe6a4 into NousResearch:main May 1, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants