From b0d2848d3354e96e4045bcc1a873d0519f1a0f1f Mon Sep 17 00:00:00 2001 From: Gabriel <96132604+Caezarr@users.noreply.github.com> Date: Wed, 2 Dec 2026 12:09:25 +0400 Subject: [PATCH 1/3] fix(loaders): treat non-finite CSV values as missing --- src/queryrouter/data/loaders.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/queryrouter/data/loaders.py b/src/queryrouter/data/loaders.py index a0fc77e..98621c3 100644 --- a/src/queryrouter/data/loaders.py +++ b/src/queryrouter/data/loaders.py @@ -56,7 +56,10 @@ class ModelProfile: def _parse_float(value: str) -> float | None: - """Parse a CSV cell as float, returning None for empty or N/A values. + """Parse a CSV cell as float, returning None for empty, N/A or non-finite values. + + ``inf`` / ``-inf`` / ``1e999`` are rejected like ``nan``: a single infinite + value would turn every min-max normalized score into NaN. Args: value: Raw string from CSV cell. @@ -69,7 +72,7 @@ def _parse_float(value: str) -> float | None: return None try: result = float(value) - return result if not math.isnan(result) else None + return result if math.isfinite(result) else None except ValueError: return None From c1c712d603941ce196457277964890e42de4268d Mon Sep 17 00:00:00 2001 From: Gabriel <96132604+Caezarr@users.noreply.github.com> Date: Wed, 2 Dec 2026 12:09:30 +0400 Subject: [PATCH 2/3] test(loaders): cover inf, -inf, Infinity and 1e999 cells --- tests/test_loaders.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_loaders.py b/tests/test_loaders.py index eb97588..9c7f3db 100644 --- a/tests/test_loaders.py +++ b/tests/test_loaders.py @@ -79,6 +79,10 @@ def test_nan(self) -> None: def test_invalid(self) -> None: assert _parse_float("not_a_number") is None + @pytest.mark.parametrize("value", ["inf", "-inf", "Infinity", "1e999"]) + def test_non_finite(self, value: str) -> None: + assert _parse_float(value) is None + class TestParseInt: def test_valid(self) -> None: From e34fdaeca2ab0a6311ee2fc646c689fb5bd4dd5e Mon Sep 17 00:00:00 2001 From: Gabriel <96132604+Caezarr@users.noreply.github.com> Date: Wed, 2 Dec 2026 12:09:35 +0400 Subject: [PATCH 3/3] docs(changelog): note non-finite CSV value handling --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f25279f..05d2b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ All notable changes to QueryRouter++ are documented here. - Unused `RouterTrainer` and query-taxonomy loader classes. ### Fixed +- **Data loading**: non-finite CSV values (`inf`, `-inf`, `1e999`) are treated as missing like `nan`, instead of turning every min-max normalized score into NaN. - **OpenAI proxy**: tool-calling turns keep `tool_calls` / `tool_call_id`, standard OpenAI params (`stop`, `seed`, `tools`, `tool_choice`, `response_format`, penalties, `max_completion_tokens`...) are forwarded upstream, and an unreachable provider returns 502 instead of 500. - `QueryRouter()` without `data_dir` now finds `data_models/`. - docker-compose health check (curl is not in the slim image); MongoDB password is required and bound to localhost.