Skip to content

fix: CLI rejects negative --max-depth and --limit values#253

Merged
raifdmueller merged 1 commit intodocToolchain:mainfrom
raifdmueller:fix/cli-negative-validation-248-249
Feb 7, 2026
Merged

fix: CLI rejects negative --max-depth and --limit values#253
raifdmueller merged 1 commit intodocToolchain:mainfrom
raifdmueller:fix/cli-negative-validation-248-249

Conversation

@raifdmueller
Copy link
Collaborator

Summary

Fixes #248, Fixes #249

Changes

  • Added non-negative validation for --max-depth in structure command (cli.py)
  • Added non-negative validation for --limit/--max-results in search command (cli.py)
  • Added 12 new tests covering both bugs (negative rejection, value in error message, zero/positive still work, aliases)
  • Bumped version to 0.4.22

Test plan

  • New tests verify negative values are rejected with clear error messages
  • New tests verify zero and positive values still work correctly
  • New tests verify aliases (str, s) also enforce validation
  • Full existing test suite passes (588 tests)

🤖 Generated with Claude Code

Copy link
Collaborator Author

@raifdmueller raifdmueller left a comment

Choose a reason for hiding this comment

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

Code Review

Overall: Very good, no issues found

Positive

  • Follows existing validation pattern from sections-at-level - good consistency
  • Clear error messages include the actual value (got -5)
  • Helpful hint text in error messages ("Use 0 for root level only, or omit for full depth")
  • 12 tests: negative values rejected, value in error message, zero/positive work, aliases tested
  • Both --max-depth and --limit/--max-results covered

Design Decision

Allowing --limit 0 (returns empty result set) is a valid choice and consistent with --max-depth 0 (returns root level only). Both are documented in the error messages.

Version Conflict

All 3 bug fix PRs bump to 0.4.22. If PRs #254 and #252 are merged first, rebase this PR and bump to 0.4.24.

Reviewed-by: R{AI}f D. Müller (AI-assisted review)

…n#248, docToolchain#249)

- structure --max-depth now validates for non-negative values
- search --limit/--max-results now validates for non-negative values
- Both use click.BadParameter with clear error messages
- Follows existing pattern from sections-at-level (Issue docToolchain#199)
- Bump version to 0.4.22

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raifdmueller raifdmueller force-pushed the fix/cli-negative-validation-248-249 branch from 5d0e4a0 to a611332 Compare February 7, 2026 10:07
@raifdmueller raifdmueller merged commit 14c08f8 into docToolchain:main Feb 7, 2026
4 checks passed
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.

CLI: search --limit accepts negative values without error CLI: structure --max-depth accepts negative values without error

1 participant