Description
Hi team! First of all, thanks for this great project — commitizen is a joy to use ❤️
I searched for existing issues on frontmatter, SPDX, and NoRevisionError but did not find anything related, so here goes.
Describe the bug
When a markdown changelog contains YAML frontmatter (delimited by ---), the regex RE_TITLE in markdown.py matches # lines inside the frontmatter as markdown headings. This causes parse_version_from_title to feed non-version text to search_version, which can extract false version numbers from it.
Example
In a changelog like:
---
# SPDX-FileCopyrightText: 2026 redtux
#
# SPDX-License-Identifier: Apache-2.0
icon: lucide/git-commit-vertical
---
# Changelog
## 0.4.0 (2026-06-08)
...The line # SPDX-License-Identifier: Apache-2.0 matches RE_TITLE, and search_version extracts 2.0 from the text apache-2.0. Since no git tag 2.0 exists, this results in NoRevisionError (exit code 16) when running cz bump --changelog.
Expected behavior
Lines within YAML frontmatter (--- delimiters) should be skipped during metadata parsing so they are not interpreted as markdown headings.
Environment
- commitizen version: 4.16.3 (installed via
uv) - Python: 3.13 (inside
uvvenv) - OS: Debian GNU/Linux Testing (forky)
Workaround / patch
The fix adds a get_metadata_from_file override in markdown.py that filters out YAML frontmatter lines before delegating to the parent parser:
def get_metadata_from_file(self, file: IO[Any]) -> Metadata:
in_fm = False
lines: list[str] = []
for line in file:
stripped = line.strip()
if stripped == "---":
in_fm = not in_fm
elif not in_fm:
lines.append(line)
return super().get_metadata_from_file(lines.__iter__())I am happy to turn this into a proper PR with tests and documentation if the approach looks good.
Activity
redtux commentedon Jun 14, 2026
Hi @bearomorphism & @Lee-W, would you be fine with a PR? Or do you rather consider this such an edge case that it's not worth fixing? I am just asking because this issue is blocking me a bit and I'd like to know how to proceed. Thanks for your feedback!
woile commentedon Jun 14, 2026
Frontmatters come in different shapes, you are assuiming
---andyaml, but those are not all the cases. We are not going to hardcode a solution that fits only your use case.You can create your own "commitizen.changelog_format"
redtux commentedon Jun 26, 2026
Thanks for the feedback!
In case anyone else needs this, I published my plugin here:
https://pypi.org/project/commitizen-spdx-changelog/
Feedback is welcome, and we can also change the plugin's name if it's too ambiguous. Finding the correct "wording" here was probably the most difficult part (and I think I failed TBH 🤭).