mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-20 22:02:20 +02:00
fix(scheduler): catch OverflowError on non-finite research settings
Catch OverflowError in addition to TypeError and ValueError when converting research_max_tokens, research_extraction_timeout_seconds, and research_extraction_concurrency to int. Non-finite numbers parsed from JSON (such as 1e309 or -1e309 representing float infinity) raise OverflowError on int() conversion, which previously escaped the handler and crashed scheduled research execution. Also add unit tests covering exponent overflow values.
This commit is contained in:
committed by
PR #6029 Reviewer
parent
8946100695
commit
c1d90beeff
@@ -15,6 +15,8 @@ same reads defensively; this is the scheduler's equivalent.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from src.task_scheduler import _resolve_research_settings
|
||||
|
||||
|
||||
@@ -77,3 +79,24 @@ def test_valid_ints_pass_through():
|
||||
)
|
||||
|
||||
assert _resolve_research_settings(get) == (2048, 120, 6)
|
||||
|
||||
|
||||
def test_non_finite_json_numbers_fall_back_individually():
|
||||
"""JSON exponent overflow produces infinity, which int() cannot convert."""
|
||||
keys = (
|
||||
"research_max_tokens",
|
||||
"research_extraction_timeout_seconds",
|
||||
"research_extraction_concurrency",
|
||||
)
|
||||
valid = (4096, 45, 2)
|
||||
defaults = (8192, 90, 3)
|
||||
|
||||
for non_finite in (json.loads("1e309"), json.loads("-1e309")):
|
||||
for index, key in enumerate(keys):
|
||||
values = dict(zip(keys, valid))
|
||||
values[key] = non_finite
|
||||
expected = list(valid)
|
||||
expected[index] = defaults[index]
|
||||
assert _resolve_research_settings(
|
||||
_fake_get_setting(values)
|
||||
) == tuple(expected)
|
||||
|
||||
Reference in New Issue
Block a user