Skip to content

fix: refuse invalid --min-rows and --max-change in check - #138

Merged
laaielichter merged 13 commits into
laaielichter:mainfrom
rohangoud17:fix-check-thresholds-106
Nov 18, 2026
Merged

laaielichter merged 13 commits into
laaielichter:mainfrom
rohangoud17:fix-check-thresholds-106

Conversation

@rohangoud17

@rohangoud17 rohangoud17 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #106

What and why

check accepted a negative --min-rows and a negative, NaN or infinite --max-change, so the check silently always passed or always failed. These are now refused the same way --range refuses bad bounds (#74).

  • Validate both thresholds at the start of parse_spec, raising a ValueError in _range_bound's message style. features.check turns it into status: "error" (exit 1), so the CLI and the Python function are both covered.
  • NaN gets its own check because nan < 0 is False.
  • --min-rows 0 and --max-change 0 stay valid.

How it was tested

  • pytest passes (864 passed, 11 Postgres skipped, on Windows)
  • ruff check . passes
  • README / AGENTS.md updated if behaviour changed (n/a: only invalid values are now rejected)

New tests: parse_spec rejects each invalid value and still accepts 0; main([...]) exits 1 with a message naming the option, and --min-rows 0 exits 0. Changelog entry added under Unreleased.

@rohangoud17 rohangoud17 changed the title Fix check thresholds 106 fix: refuse invalid --min-rows and --max-change in check Nov 10, 2026

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rohangoud17, and thanks for following the pointer to parse_spec. #106 is yours (you asked on 2026-11-09 at 19:07 and were assigned the next morning), and the code does what the issue asks. One small CHANGELOG fix and it is ready.

What I checked. I merged 60df34a onto current main (c48adf8) in a scratch worktree: clean merge, ruff check . passes, pytest -q gives 883 passed, 10 skipped. Against #106's "Done when":

  • By hand through the CLI on the demo database: --min-rows -5, --max-change -5, --max-change nan and --max-change inf each return status: "error" with a message naming the option, exit code 1, and no query runs. --min-rows 0 and --max-change 0 stay valid (exit 0).
  • Tests exist through parse_spec and through main([...]), for every refused value, plus the two zero cases.
  • The diff only touches checks.py, two test files and the CHANGELOG, so nothing outside the scope, and no change to how SQL is built or run.

Please fix: the CHANGELOG line.

  1. Typo: "NaN orinfinite" should be "NaN or infinite".
  2. The new bullet is at the top of ### Fixed. Other open PRs add theirs there too, so they would all conflict. Please move it to the end of the existing ### Fixed list (just above ### Changed), then push.

CI: both runs for this commit (ci, codeql) are action_required, which is GitHub holding a first-time contributor's run until a maintainer approves it, so no check has run yet.

Heads-up: other open PRs also add tests at the end of tests/test_cli_and_mcp.py; if that conflicts later, merge main and keep both blocks.


Generated by Claude Code

rohangoud17 and others added 2 commits November 11, 2026 12:32
Updated changelog with recent fixes, changes, and acknowledgments.
@rohangoud17

Copy link
Copy Markdown
Contributor Author

Fixed the changelog typo, moved the entry to the end of ### Fixed, and merged main to resolve the conflict in tests/test_cli_and_mcp.py (kept both test blocks). pytest and ruff check . pass locally. Ready for another look

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rohangoud17 for the quick update: the typo is fixed, the conflict is resolved with both test blocks kept, and the code is unchanged from what I already checked. One thing is left, and it comes from the 0.4.0 release that landed in between.

What I checked. I merged 28a0af8 onto current main (2bdae73; main is already an ancestor, so it is a clean merge) in a scratch worktree on Python 3.13 / Linux: ruff check . passes and pytest -q gives 895 passed, 10 skipped. The diff is still only checks.py, two test files and the CHANGELOG, and the #106 "Done when" list is still met (negative --min-rows, negative / NaN / infinite --max-change refused with exit 1; 0 stays valid).

Please fix: the CHANGELOG line is inside the released 0.4.0 section. Main now has ## 0.4.0 - 2026-11-11, and your bullet sits at the end of that section's ### Fixed list (around line 61), so it would be reported as shipped in 0.4.0 when it was not. New entries go under a new ## Unreleased heading above ## 0.4.0:

# 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

Then remove the line from the 0.4.0 list. If another PR has already added ## Unreleased by the time you push, merge main and just add your bullet at the end of its ### Fixed list.

One tiny thing while you are there: git diff --check flags a blank line at the end of tests/test_cli_and_mcp.py (line 175); please drop it.

CI: the ci and codeql runs for this head are action_required, so GitHub is still waiting for a maintainer to approve them; no check has run on GitHub yet. That is not a failure on your side.


Generated by Claude Code

@rohangoud17

Copy link
Copy Markdown
Contributor Author

Thanks for catching that! I moved the entry to a new ## Unreleased section above 0.4.0, removed it from the 0.4.0 ### Fixed list, and dropped the trailing blank line in tests/test_cli_and_mcp.py. git diff --check is clean, and pytest and ruff check . pass locally.

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @rohangoud17: both things I asked for are done, and quickly. The entry now sits under a new ## Unreleased / ### Fixed above ## 0.4.0, it is gone from the 0.4.0 list, and the trailing blank line in tests/test_cli_and_mcp.py is dropped. This is approved from my side.

What I checked on head 0934626:

  • Delta since 28a0af8: only CHANGELOG.md (the bullet moved as asked, wording unchanged) and the one removed blank line in tests/test_cli_and_mcp.py. The code in checks.py is the same I already reviewed. Scope is still four files (checks.py, two test files, CHANGELOG), nothing touches how SQL is built or run.
  • Merged onto current main (2bdae73, which is the base of your branch, so a clean fast-forward) in a scratch worktree with a fresh venv on Python 3.13 / Linux: ruff check . passes, pytest -q gives 895 passed, 10 skipped, and git diff --check is clean.
  • By hand through the CLI on a small DuckDB table: --min-rows -5, --max-change -5, --max-change nan and --max-change inf each return status: "error" with a message naming the option and exit code 1; --min-rows 0 and --max-change 0 still return ok (exit 0).

CI: the ci and codeql runs for this head are action_required (GitHub holds a first-time contributor's run until a maintainer approves it), so no check has run on GitHub yet. This repository requires 11 checks, so I am not merging this myself; it waits for the maintainer to approve the runs and for them to go green.

Thanks again for sticking with it through the review rounds.


Generated by Claude Code

Copy link
Copy Markdown
Owner

@rohangoud17 a heads-up: #147 landed today and added its line to ## Unreleased / ### Fixed in CHANGELOG.md, right where this PR adds its own, so this PR now conflicts with main in that file only. Could you merge main into your branch and keep both lines, yours at the end of the ### Fixed list? The code stays approved. CI can only run once the conflict is gone, and its runs then wait for the maintainer's approval.


Generated by Claude Code

@rohangoud17

rohangoud17 commented Nov 14, 2026 via email

Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Owner

Thank you @rohangoud17 for merging main. Re-checked: only CHANGELOG changed since approval (head d7235a1; the src/ and tests/ diff against main is identical to the version I approved), and the branch now merges cleanly. Waiting for CI approval by the maintainer.


Generated by Claude Code

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @rohangoud17 for merging main in. Still approved on d7235a1.

Compared with 0934626, which I approved, the only change is the merge of current main (52666d3); checks.py, the tests and your CHANGELOG line are the same, and the merge is clean. With this head: ruff check . passes, git diff --check is clean and pytest -q gives 888 passed, 10 skipped.

CI: the ci and codeql runs for this head are action_required until a maintainer approves them, and Gulliver needs all 14 checks green, so I am not merging yet.


Generated by Claude Code

Copy link
Copy Markdown
Owner

@rohangoud17 a heads-up: other PRs landed on main today and added their CHANGELOG lines in ## Unreleased, right where this PR adds its own, so this PR now conflicts with main in that file. Could you merge main into your branch and keep all the lines (yours at the end of the list)? The code stays approved and CI was green on this head. After the merge, the CI runs wait for the maintainer's approval once more.


Generated by Claude Code

Copy link
Copy Markdown
Owner

Good news for part of the conflict: the CHANGELOG part got easier. We changed the rule so contributors don't edit CHANGELOG.md any more; we add your entry with credit when we merge. When you merge main, just take main's version of CHANGELOG.md (or drop your change to it). The conflict in tests/test_cli_and_mcp.py still needs a normal merge of main.


Generated by Claude Code

Copy link
Copy Markdown
Owner

Thanks @rohangoud17, the --min-rows and --max-change refusals are the right behaviour. Two things block the merge:

  1. tests/test_cli_and_mcp.py has two stray lines, fix-check-thresholds-106 and main, between two tests (most likely pasted during the merge). They raise NameError: name 'fix' is not defined while pytest collects that module, so the whole suite fails. Deleting those two lines is enough: with them removed, the full suite passes here (1013 passed, 10 skipped) and ruff check . is clean.
  2. CHANGELOG.md has a new line. Contributors no longer edit it; the maintainer adds the entry with credit when the PR is merged. Please drop that change (merging main and taking main's CHANGELOG.md is the easy way).

Once both are pushed, the CI runs wait for a maintainer approval again, and we will review the new head.


Generated by Claude Code

@rohangoud17

Copy link
Copy Markdown
Contributor Author

Merged main: took main’s CHANGELOG and kept both test blocks in tests/test_cli_and_mcp.py. Thanks!

Copy link
Copy Markdown
Owner

Thanks @rohangoud17. The two stray lines are gone, and the code works. I merged current main into head fdbb0c5 locally: pytest -q gives 1148 passed, 10 skipped, ruff check . is clean and git diff --check is clean. Through the CLI, --min-rows -5 and --max-change nan now return status: error with exit code 1, where main returns ok, and --min-rows 0 still passes. Removing either guard makes the new tests fail, so the tests cover the fix.

One thing is left: the branch still adds a line to CHANGELOG.md, the check now refuses a negative --min-rows ... bullet under ## Unreleased / ### Fixed. It is probably left over from an earlier merge. Please restore main's version and push:

git fetch upstream main
git checkout upstream/main -- CHANGELOG.md
git commit -m "Drop CHANGELOG change"

After that, git diff upstream/main --stat should list only src/gulliver/checks.py and the two test files. I'll add the entry with credit when this merges.

Optional, not required for this PR: since #174, parse_spec reports bad flag values with UsageError(message, example), so the message names the flag and comes with a concrete next_step, as --max-null and --range do. If you would like to switch the two new checks to that style (--min-rows needs 0 or more, got -5), you are welcome to, but the current ValueError is fine.

When you push, the CI runs will need maintainer approval again. I'll approve them once I've checked the new head.


Generated by Claude Code

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rohangoud17. I reproduced #106 on main: check events --min-rows -5 and --max-change nan both get as far as the query. On this branch both are refused with exit 1 and a message that names the option, and --min-rows 0 still works. The head passes the suite on its own (1149 passed after merging main, ruff clean).

Before it can merge:

  1. Remove the CHANGELOG.md line. The maintainer writes that entry (as we asked earlier on this PR).
  2. The PR is blocked: the CI workflows have not run on this head yet. Once they are green, it can go.

Welcome to Gulliver! CONTRIBUTING.md has the setup steps (pip install -e ".[dev]", pytest, ruff check .). A free next issue is #120 (check --not-null "" passes with nothing checked), labeled good first issue.

If Gulliver is useful to you, a ⭐ helps other people find it.


Generated by Claude Code

@rohangoud17

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the welcome!

Removed the CHANGELOG.md line; the PR now only touches checks.py and the tests.
Pushed, so there's a new head for CI. As a first-time contributor, I think the workflows need a maintainer's "Approve and run" before they start.

Copy link
Copy Markdown
Owner

Thanks @rohangoud17. The CHANGELOG.md change is gone, and the PR now touches only checks.py and the test files, as asked. Whether the CI runs on this head are approved is the maintainer's decision, and the maintainer will check the new head before deciding.


Generated by Claude Code

@laaielichter
laaielichter merged commit b46fee3 into laaielichter:main Nov 18, 2026
14 checks passed
laaielichter added a commit that referenced this pull request Nov 18, 2026
laaielichter added a commit that referenced this pull request Nov 18, 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.

check: refuse a negative --min-rows and a negative, NaN or infinite --max-change

2 participants