Description
When message_length_limit is configured (e.g., in pyproject.toml), cz commit / cz check should enforce it unless the user explicitly overrides it via the CLI -l/--message-length-limit.
Currently, if the CLI argument exists but is None/unset, the code path ends up treating it as “no limit”, so the configured limit is not applied.
Reason why:
argparse leaves message_length_limit as None when the flag isn’t provided (no default is set). eg. cz commit
- Because the key still exists in arguments,
arguments.get("message_length_limit", ...) returns None and never falls back to config.settings, effectively bypassing the configured limit.
Steps to reproduce
- Create a
pyproject.toml with:
[tool.commitizen]
name = "cz_conventional_commits"
message_length_limit = 10
- Run either:
cz check --message "feat: this is definitely too long"
- or
cz commit --dry-run and enter a subject that makes the first line longer than 10 characters.
- Ensure you did not pass -l/--message-length-limit.
Current behavior
The configured message_length_limit from pyproject.toml is not enforced when the CLI flag is unset, allowing too-long subjects to pass.
Desired behavior
- Enforce
message_length_limit from config when -l/--message-length-limit is not provided.
- Precedence should be CLI > config > default (0 = no limit).
-l 0 should explicitly disable the limit even if config sets one.
Screenshots
Environment
Commitizen Version: 4.13.9
Python Version: 3.14.3 (main, Feb 3 2026, 15:32:20) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Operating System: Darwin
Description
When
message_length_limitis configured (e.g., inpyproject.toml),cz commit / cz checkshould enforce it unless the user explicitly overrides it via the CLI-l/--message-length-limit.Currently, if the CLI argument exists but is
None/unset, the code path ends up treating it as “no limit”, so the configured limit is not applied.Reason why:
argparseleavesmessage_length_limitasNonewhen the flag isn’t provided (no default is set). eg.cz commitarguments.get("message_length_limit", ...)returnsNoneand never falls back toconfig.settings, effectively bypassing the configured limit.Steps to reproduce
pyproject.tomlwith:cz check --message "feat: this is definitely too long"cz commit --dry-runand enter a subject that makes the first line longer than 10 characters.Current behavior
The configured
message_length_limitfrompyproject.tomlis not enforced when the CLI flag is unset, allowing too-long subjects to pass.Desired behavior
message_length_limitfrom config when-l/--message-length-limitis not provided.-l 0should explicitly disable the limit even if config sets one.Screenshots
Environment
Commitizen Version: 4.13.9
Python Version: 3.14.3 (main, Feb 3 2026, 15:32:20) [Clang 15.0.0 (clang-1500.1.0.2.5)]
Operating System: Darwin