Skip to content

[bugfix] Reject invalid --kernel-size with a usage error instead of a traceback (#604) - #605

Merged
Breakthrough merged 4 commits into
Breakthrough:mainfrom
goranai:bugfix/kernel-size-validation
Nov 16, 2026
Merged

Breakthrough merged 4 commits into
Breakthrough:mainfrom
goranai:bugfix/kernel-size-validation

Conversation

@goranai

@goranai goranai commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Closes #604

-k/--kernel-size of detect-content and detect-adaptive was passed to ContentDetector unchecked, so 1, even or negative values ended in a ValueError traceback. It is now validated in CliContext and reported as click.BadParameter, as --weights and --downscale already are:

Error: Invalid value for kernel-size: Kernel size must be an odd integer >= 3.

KernelSizeValue also accepted kernel-size = 1 from a config file, contrary to its docstring, and the detector then raised. It now rejects values below 3 (except -1 = auto), and its message says ">= 3", matching the CLI help, scenedetect.cfg and the docs.

Note: on the command line -k -1 is now also rejected with a usage error. The CLI help never documented -1 for -k (only the config file does), and today -k -1 crashes with the same traceback.

Tests: test_cli_kernel_size_rejects_invalid (3 CLI cases) and test_cli_kernel_size_config_file_rejects_one (2 config cases) fail on main (5 failed) and pass with this change (5 passed). In the full suite the only failures are 2 moviepy tests that fail the same way on main because moviepy is not installed locally.

AI disclosure: prepared with Claude Code (Claude Opus 5.5) and reviewed by me.

🤖 Generated with Claude Code

… traceback (Breakthrough#604)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Breakthrough Breakthrough 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 for the PR, have a few small changes to ask, but other than these LGTM.

Comment thread scenedetect/_cli/context.py Resolved
Comment thread tests/test_cli.py Resolved
Comment thread scenedetect/_cli/config.py Resolved
)

Adds tests for -k -1, negative and valid sizes, and a changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@goranai

goranai commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

All three points are done in 4a4b66e: -k goes through KernelSizeValue, the tests cover -k -3, -2, 3 and -1, and the changelog has the 0.8 entry. Could you take another look when you have time?

# Conflicts:
#	website/pages/changelog.md
# Conflicts:
#	website/pages/changelog.md
@Breakthrough
Breakthrough merged commit 8f91c02 into Breakthrough:main Nov 16, 2026
23 checks passed
@Breakthrough Breakthrough added this to the 0.7.4 milestone 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.

detect-content / detect-adaptive -k with an invalid kernel size crashes with a traceback; config accepts kernel-size = 1

3 participants