From b71ce10e9c5f663cf3d6cbf95edc087307d34870 Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Tue, 10 Nov 2026 14:26:11 -0500 Subject: [PATCH 1/9] refuce negative min_rows and negative/Nan/infinite max_change in parse_spec --- src/gulliver/checks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gulliver/checks.py b/src/gulliver/checks.py index 3e664d7..c5a2a8e 100644 --- a/src/gulliver/checks.py +++ b/src/gulliver/checks.py @@ -36,6 +36,10 @@ def parse_spec(unique: list[str] | None = None, not_null: list[str] | None = Non max_change_pct: float | None = None) -> CheckSpec: """Parse CLI-style strings: unique 'id' or 'a,b'; accepted 'status=new|paid'; range 'amount=0:1000'; fresh 'ts=24h'.""" + if min_rows is not None and min_rows < 0: + raise ValueError(f"min_rows needs 0 or more, got {min_rows!r}") + if max_change_pct is not None and not (math.isfinite(max_change_pct) and max_change_pct >= 0): + raise ValueError(f"max_change needs a finite number, 0 or more, got {max_change_pct!r}") spec = CheckSpec(min_rows=min_rows, max_change_pct=max_change_pct) for u in unique or []: spec.unique.append([c.strip() for c in u.split(",") if c.strip()]) From 59cfa02ce112132d28f2a06d431549e0cc443cff Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Tue, 10 Nov 2026 14:49:26 -0500 Subject: [PATCH 2/9] test: cover invalid min_rows and max_change in parse_spec --- tests/test_checks.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_checks.py b/tests/test_checks.py index 7bd5004..74c5f71 100644 --- a/tests/test_checks.py +++ b/tests/test_checks.py @@ -6,12 +6,27 @@ def _bounds(text): return parse_spec(ranges=[f"amount={text}"]).ranges["amount"] +@pytest.mark.parametrize("value", [-1, -5]) +def test_min_rows_refuses_negative(value): + with pytest.raises(ValueError, match=r"min_rows needs 0 or more"): + parse_spec(min_rows=value) + +@pytest.mark.parametrize("value", [-5.0, float("nan"), float("inf"), float("-inf")]) +def test_max_change_refuses_negative_or_non_finite(value): + with pytest.raises(ValueError, match=r"max_change needs a finite number"): + parse_spec(max_change_pct=value) + + @pytest.mark.parametrize("text", ["nan:", ":inf", "-inf:", ":nan"]) def test_range_refuses_non_finite_bounds(text): with pytest.raises(ValueError, match="finite"): parse_spec(ranges=[f"amount={text}"]) +def test_zero_thresholds_still_parse(): + spec = parse_spec(min_rows=0, max_change_pct=0.0) + assert spec.min_rows == 0 + assert spec.max_change_pct == 0.0 def test_range_refuses_a_non_number(): with pytest.raises(ValueError, match=r"range for 'amount' needs numbers, got 'abc'"): From bb399b9bb320e9acc1868d4fd17be1059bf58421 Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Tue, 10 Nov 2026 15:01:12 -0500 Subject: [PATCH 3/9] test: cover invalid threshold through main() --- tests/test_cli_and_mcp.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_cli_and_mcp.py b/tests/test_cli_and_mcp.py index 7e1d67f..eebd91f 100644 --- a/tests/test_cli_and_mcp.py +++ b/tests/test_cli_and_mcp.py @@ -1,6 +1,8 @@ import asyncio import json +import pytest + from gulliver.cli import main from gulliver.mcp_server import build_server, export_tools @@ -97,3 +99,18 @@ def test_cli_translate_output_file(tmp_path, capsys): data = json.loads(capsys.readouterr().out) assert data["warnings"] # still printed assert out.read_text(encoding="utf-8") == data["sql"] + +@pytest.mark.parametrize("extra, message", [ + (["--min-rows", "-5"], "min_rows"), + (["--max-change", "-5"], "max_change"), + (["--max-change", "nan"], "max_change"), + (["--max-change", "inf"], "max_change"), +]) +def test_check_refuses_invalid_thresholds(demo_db, capsys, extra, message): + code = main(["--dsn", demo_db, "--json", "check", "events", "--not-null", "event_id", *extra]) + assert code == 1 + assert message in capsys.readouterr().out + + +def test_check_accepts_zero_min_rows(demo_db): + assert main(["--dsn", demo_db, "--json", "check", "events", "--not-null", "event_id", "--min-rows", "0"]) == 0 From 60df34a97cb5b1529f231eb3481eb7a1ad67dde1 Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Tue, 10 Nov 2026 15:02:50 -0500 Subject: [PATCH 4/9] Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e325bb..8678ef1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ - @abu-tahir-0 for five fixes on their first day: strict `check --range` bounds (#85), one row-count history per connection (#86), whole-number and non-boolean budget limits (#84), refusing unknown `gulliver.toml` sections (#83) and GV013 for leading `_` (#82). ### Fixed +- `check` now refuses a negative `--min-rows` and a negative, NaN orinfinite `--max-change` instead of silently passing or failing (#106). - `spend --days N`, `calibration --days N` and `top --limit N` refuse a value below 1 with `status: error` and a `next_step`, and exit 1 instead of quietly reporting an empty or off-by-one window. `top --analyze` refuses a negative value too, while `--analyze 0` still lists the groups without analysing them (#92). - `check --range` refuses `nan`, infinite and non-numeric bounds and an inverted `min > max` before any query runs, naming the column. Before, `nan` / `inf` reached the engine as column names and an inverted range silently failed every row (#74, #85). - `check --max-change` keys the row-count history on the resolved connection name, so a check with and without `-c default` shares one history. Histories saved under the old key are still read and migrated (#75, #86). From 39c611f0048c683b37c52837b5757a12d2e28a61 Mon Sep 17 00:00:00 2001 From: rohangoud17 <150305286+rohangoud17@users.noreply.github.com> Date: Wed, 11 Nov 2026 12:32:43 -0500 Subject: [PATCH 5/9] Revise CHANGELOG.md for recent updates and fixes Updated changelog with recent fixes, changes, and acknowledgments. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8678ef1..8bb1bad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,7 +34,6 @@ - @abu-tahir-0 for five fixes on their first day: strict `check --range` bounds (#85), one row-count history per connection (#86), whole-number and non-boolean budget limits (#84), refusing unknown `gulliver.toml` sections (#83) and GV013 for leading `_` (#82). ### Fixed -- `check` now refuses a negative `--min-rows` and a negative, NaN orinfinite `--max-change` instead of silently passing or failing (#106). - `spend --days N`, `calibration --days N` and `top --limit N` refuse a value below 1 with `status: error` and a `next_step`, and exit 1 instead of quietly reporting an empty or off-by-one window. `top --analyze` refuses a negative value too, while `--analyze 0` still lists the groups without analysing them (#92). - `check --range` refuses `nan`, infinite and non-numeric bounds and an inverted `min > max` before any query runs, naming the column. Before, `nan` / `inf` reached the engine as column names and an inverted range silently failed every row (#74, #85). - `check --max-change` keys the row-count history on the resolved connection name, so a check with and without `-c default` shares one history. Histories saved under the old key are still read and migrated (#75, #86). @@ -50,6 +49,7 @@ - New test `tests/test_tool_annotations.py`: read-only tools may not describe writes. - `gulliver_check` is no longer annotated read-only either: it stores the row count locally for the next `max_change_pct` comparison. - Receipt ids now carry 64 random bits instead of 32. With 32 bits, two ids made in the same second collided about 1 in 300 times over 5000 ids (seen as a flaky CI test on macOS). The prompt-injection guard recognizes the longer ids. +- `check` now refuses a negative `--min-rows` and a negative, NaN or infinite `--max-change` instead of silently passing or failing (#106). ### Changed - Lint rule GV013 `leading-wildcard-like` also flags `LIKE` / `ILIKE` patterns that start with the `_` wildcard; an escaped `\_` stays unflagged (#78, #82). From bfc7c92583637a4bd3bfdb992f792a089a90b5b4 Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Wed, 11 Nov 2026 14:23:27 -0500 Subject: [PATCH 6/9] docs: move #106 to unreleased --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 325a237..23eb596 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Unreleased + +### Fixed +- `check` now refuses a negative `--min-rows` and a negative, NaN or infinite `--max-change` instead of silently passing or failing (#106). + ## 0.4.0 - 2026-11-11 Data checks you define once in `gulliver.toml` and run in CI, a lint baseline for existing repos, rehearsal @@ -58,7 +63,6 @@ and flags. Thanks to 14 outside contributors. - New test `tests/test_tool_annotations.py`: read-only tools may not describe writes. - `gulliver_check` is no longer annotated read-only either: it stores the row count locally for the next `max_change_pct` comparison. - Receipt ids now carry 64 random bits instead of 32. With 32 bits, two ids made in the same second collided about 1 in 300 times over 5000 ids (seen as a flaky CI test on macOS). The prompt-injection guard recognizes the longer ids. -- `check` now refuses a negative `--min-rows` and a negative, NaN or infinite `--max-change` instead of silently passing or failing (#106). ### Changed - Lint rule GV013 `leading-wildcard-like` also flags `LIKE` / `ILIKE` patterns that start with the `_` wildcard; an escaped `\_` stays unflagged (#78, #82). From 12923450ce9e0ac1377f484c2e1f7dd3f97931ce Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Wed, 11 Nov 2026 14:27:59 -0500 Subject: [PATCH 7/9] Test: drop trailing blank line --- tests/test_cli_and_mcp.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_cli_and_mcp.py b/tests/test_cli_and_mcp.py index b18e736..68797b9 100644 --- a/tests/test_cli_and_mcp.py +++ b/tests/test_cli_and_mcp.py @@ -171,5 +171,4 @@ def test_mcp_check_by_name_and_status_checks(demo_db, state, tmp_path, monkeypat elif hasattr(err_res, "content") and err_res.content: err_data = json.loads(err_res.content[0].text) assert err_data.get("status") == "error" - assert "Unknown configured check" in err_data.get("error", "") - + assert "Unknown configured check" in err_data.get("error", "") \ No newline at end of file From 0934626da23ced5dd87d7d2ad9f4c5c1f6d87536 Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Wed, 11 Nov 2026 14:29:02 -0500 Subject: [PATCH 8/9] fixed ruff error and dropped trailing blank line --- tests/test_cli_and_mcp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_cli_and_mcp.py b/tests/test_cli_and_mcp.py index 68797b9..1852542 100644 --- a/tests/test_cli_and_mcp.py +++ b/tests/test_cli_and_mcp.py @@ -171,4 +171,4 @@ def test_mcp_check_by_name_and_status_checks(demo_db, state, tmp_path, monkeypat elif hasattr(err_res, "content") and err_res.content: err_data = json.loads(err_res.content[0].text) assert err_data.get("status") == "error" - assert "Unknown configured check" in err_data.get("error", "") \ No newline at end of file + assert "Unknown configured check" in err_data.get("error", "") From 2bc7424080cfff3e91a309d081fceba7ac1fdaf4 Mon Sep 17 00:00:00 2001 From: rohangoud17 Date: Tue, 17 Nov 2026 10:59:27 -0500 Subject: [PATCH 9/9] docs(changelog): drop the #106 entry; the maintainer writes it --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61815c9..8ffe545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ ### Fixed - Lint GV003 now reports a join whose `ON` condition does not relate the two tables (`ON 1=1`, `ON TRUE`, `ON t.id = t.id`) as a cartesian product (error) instead of passing it as a key join. A real key, with or without extra conditions, and unqualified columns are unchanged. Thanks to @Ipsita-Mondal-30! (#156, #164) - `impact`, `lineage` and `drift` refuse `--models` pointing to a folder with no `.sql` files with `status: error` and a `next_step` instead of reporting zero models or empty impact. Thanks to @shaw778! (#122, #147) -- `check` now refuses a negative `--min-rows` and a negative, NaN or infinite `--max-change` instead of silently passing or failing (#106). - `gulliver fix --verify --cases N` refuses a value below 1 with `status: error` and a `next_step`, before any rewrite is verified. Before, `--cases 0` became the default of 200 and `--cases -5` ran one case and reported `status: "ok"`, which is a weaker guarantee than it reads. The MCP tool already refused these with `ge=1`. `--cases` without `--verify` is still ignored Thanks to @tyza66! (#111, #117) - `parse_period` refuses an out-of-range period with `ValueError` and a clear message, so `prune --older-than 99999999999d`, `check --fresh ts=99999999999d` and `incremental --period 99999999999d` return `status: "error"` and exit 1 instead of an `OverflowError` traceback. Huge values in hours, minutes and weeks are refused the same way as days, and valid periods are unchanged Thanks to @draarivpatel-ui! (#108, #110) - `run --max-rows N` refuses a value below 0 with `status: error` and a `next_step`, exits 1, and skips estimating, running, or writing a receipt, while `--max-rows 0` stays valid. Thanks to @dianatofficial! (#119, #121)