Title: fix(changelog): clearer error when changelog format cannot be inferred by bearomorphism · Pull Request #1973 · commitizen-tools/commitizen · GitHub
Open Graph Title: fix(changelog): clearer error when changelog format cannot be inferred by bearomorphism · Pull Request #1973 · commitizen-tools/commitizen
X Title: fix(changelog): clearer error when changelog format cannot be inferred by bearomorphism · Pull Request #1973 · commitizen-tools/commitizen
Description: Description
Closes #894.
Why
Since commitizen 3.12, running cz changelog with a non-standard --file-name such as docs/source/changelog.md.sections (a Sphinx-style sectioned changelog file) fails with the message Unknown changelog format 'None'. The error is cryptic: it exposes an internal None Python value rather than explaining what went wrong or what the user should do.
The failure path is get_changelog_format (commitizen/changelog_formats/__init__.py:64–80). When changelog_format is not set in the config, name is None. The function then calls _guess_changelog_format(filename) (__init__.py:83–98), which matches the filename against known extensions. A filename like changelog.md.sections does not end with .md — endswith requires the final suffix — so inference returns None. At line 78, the single raise path always formats the message as f"Unknown changelog format '{name}'", which prints Unknown changelog format 'None' regardless of whether the problem was a bad explicit setting or a failed inference. The original reporter (@gsemet) filed the issue in October 2023; a second user (@anthonyfinch) hit the same problem shortly after, and triage in #1964 confirmed the bug is still present against master (v4.15.1).
The fix splits the error into two distinct, actionable messages — one for each failure mode — and both messages list the registered format names so users know exactly what to write in changelog_format.
What changed
File
Change
commitizen/changelog_formats/__init__.py
Split the single raise ChangelogFormatUnknown in get_changelog_format (line 78) into two branches: one for an explicitly-set-but-unknown name, one for inference failure; both append Known formats:
Open Graph Description: Description Closes #894. Why Since commitizen 3.12, running cz changelog with a non-standard --file-name such as docs/source/changelog.md.sections (a Sphinx-style sectioned changelog file) fails wi...
X Description: Description Closes #894. Why Since commitizen 3.12, running cz changelog with a non-standard --file-name such as docs/source/changelog.md.sections (a Sphinx-style sectioned changelog file) fails wi...
Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1973
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:bf73d73e-5c63-64d3-15f7-22ba303a7ff0 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | CA3C:2095E1:2827885:37AAA6A:6A4F566E |
| html-safe-nonce | 8c105d9f92edcfa0725b0a34317e23f7e94ff963de02cc05c0214a4424b2907f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQTNDOjIwOTVFMToyODI3ODg1OjM3QUFBNkE6NkE0RjU2NkUiLCJ2aXNpdG9yX2lkIjoiNzAyMzA0MTk0MDUwMjMwNDM2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f0d7aa6aa67dd1941925ccbbf81a972f83f3a21ea253601fb35d39d7767466c6 |
| hovercard-subject-tag | pull_request:3654729169 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1973/files |
| twitter:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/26526132?s=400&v=4 |
| og:image:alt | Description Closes #894. Why Since commitizen 3.12, running cz changelog with a non-standard --file-name such as docs/source/changelog.md.sections (a Sphinx-style sectioned changelog file) fails wi... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git |
| octolytics-dimension-user_id | 62252524 |
| octolytics-dimension-user_login | commitizen-tools |
| octolytics-dimension-repository_id | 106127589 |
| octolytics-dimension-repository_nwo | commitizen-tools/commitizen |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 106127589 |
| octolytics-dimension-repository_network_root_nwo | commitizen-tools/commitizen |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b14b8c6d72fdb96ca48aba85dec94fe96ce5adbe |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width