Skip to content

Report invalid config section types without tracebacks (#126) - #144

Merged
laaielichter merged 2 commits into
laaielichter:mainfrom
amritkang165:fix/config-section-types
Nov 16, 2026
Merged

laaielichter merged 2 commits into
laaielichter:mainfrom
amritkang165:fix/config-section-types

Conversation

@amritkang165

@amritkang165 amritkang165 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What and why

A plain value where a config table belongs can crash Gulliver or silently fall back to defaults. This checks the types of budget, connections, named connection entries, approval, lint and review before reading their keys. Invalid sections raise ConfigError, naming the section and the expected table type.

The check also rejects empty strings, arrays, zero and false instead of treating them as missing sections. Missing sections and valid tables keep their defaults and overrides. SQL-string linting now validates its lint config as file linting already does.

Fixes #126. Includes regression tests and configuration guidance.

How it was tested

  • pytest -q: 1047 passed, 10 skipped (no live PostgreSQL test database configured)
  • ruff check .: passed
  • README / AGENTS.md, llms.txt and the skill updated
  • git diff --check: passed

The initial regression run against the original code had 43 failures and two passing compatibility cases. The final tests cover all six affected sections, invalid scalar and array values, valid empty/inline tables, overrides, file linting and SQL-string linting with an explicit dialect.

Also ran all six issue examples through the real CLI. Each returns status: "error", exit code 1 and next_step: "Fix gulliver.toml or the flags.", without a traceback. For example, budget = 3 now reports:

[budget] must be a table (a [budget] section with keys), not int.

Merged current main on 2026-11-15 and kept its CHANGELOG.md unchanged, following the updated contribution guide. The security self-test also passes all 151 corpus cases and all sandbox checks.

@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 @amritkang165, this is a clean fix for #126. One small table_section helper replaces all the unchecked data.get(...) or {} reads, and treating 0, false, "" and [] as wrong types (instead of silently "missing") is exactly the right call.

I merged 18cf60d onto current main (2bdae73) and checked:

  • ruff check . passes; pytest -q gives 929 passed, 10 skipped. Your new tests fail on main (44 failed) and pass with your change (46 passed).
  • By hand through the real CLI: budget = 3, connections = "x", [connections] x = 1, lint = 5 (SQL string, a folder, and with --dialect), review = 3, approval = "cli". Each gives a one-line error naming the section and "must be a table ... not int/str", status: "error", next_step: "Fix gulliver.toml or the flags.", exit 1, no traceback. review prints its usual markdown error. The same holds via --dsn, GULLIVER_DSN, GULLIVER_CONFIG and a gulliver.toml in the working directory.
  • Valid files are unchanged: gulliver.example.toml, an empty file, empty/inline tables and [budget]/[connections.x] overrides all load as before.
  • The diff touches no workflows, packages, network or exec code and has no personal data. The CHANGELOG line sits under ## Unreleased above ## 0.4.0, and the docs/skill notes match what the CLI prints.

One behaviour to be aware of, not a blocker: gulliver --config missing.toml lint "SELECT 1" now reports "Config file not found" because the SQL-string path loads [lint]; before it quietly linted. That matches how file linting already behaves and seems right to me.

Our CI needs a maintainer to approve the workflow run for a fork PR, so it has not run yet. Once it is green this is good to merge, and we will add your credit to the release notes. Since you have #137 and #139 in flight too, a good next one is any open good first issue; I would suggest picking another config-validation one if you want to stay in this area.


Generated by Claude Code

Copy link
Copy Markdown
Owner

@amritkang165 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. The same applies to #139; I left a note there.


Generated by Claude Code

Copy link
Copy Markdown
Owner

Good news: you no longer need to resolve the CHANGELOG conflict. We changed the rule so contributors don't edit CHANGELOG.md any more; we add your entry with credit when we merge. Easiest fix: drop your CHANGELOG.md change (or merge main and take main's version of the file) and push; the rest of the PR is unchanged.


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.

Checked the head locally: full suite 1047 passed, 10 skipped; ruff check . clean. The #126 config from the issue crashed on main with a TypeError; on this head it returns status: error with "[connections.x] must be a table ..." and no traceback. The new tests fail on main (44 failures), so they cover the change.

Thanks @amritkang165 for the thorough section checks and tests.


Generated by Claude Code

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

gulliver.toml: a section with the wrong type (budget = 3, lint = 5, [connections] x = 1) crashes with a Python traceback

2 participants