fix: normalize dev versions to valid SemVer strings - #15270
fix: normalize dev versions to valid SemVer strings#15270SatyamPandey-07 wants to merge 1 commit into
Conversation
|
👋 Hi @SatyamPandey-07, thanks for contributing! For the review process to begin, please verify that the following is satisfied:
Also check that issue requirements are satisfied & you ran Pull requests that don't follow the guidelines will be closed. Reviewer assignment can take up to 2 weeks. |
|
@AlexVelezLl just bumping this PR in case it slipped through your notifications. Let me know if you need any changes or further testing! |
|
@rtibbles just bumping this PR in case it slipped through your notifications. Let me know if you need any changes or further testing! |
Summary
setuptools-scmemits fallback development versions such as0.1.dev38363+g356cfe2f5. During module initialization,kolibri.core.upgradepasseskolibri.__version__throughnormalize_version_to_semver()before parsing it withsemver.VersionInfo.parse(). Due to a regex flaw innormalize_version_to_semver(), the preceding dot before.devwas captured into the numeric prefix and.devwas duplicated into bothafteranddev, producing0.1.-dev38363.dev38363.g356cfe2f5. This causessemver.VersionInfo.parse()to raise an unhandledValueError: ... is not valid SemVer string, breaking pytest and Django startup entirely. Similarly, standard post-release dev strings like0.1.2.dev6+gdef09150resulted in0.1.2-dev6.dev6.gdef09150..devsuffix separately so the dev fragment is never matched twice.^\d+\.\d+(?:\.\d+)?to prevent trailing dot leakage into the numeric prefix.0.1.dev...) receive a.0patch segment so they comply with SemVer'sMAJOR.MINOR.PATCHspecification.0.15.0,1.10,0.14a1,0.16b1).kolibri/utils/tests/test_version.pyfor bothsetuptools-scmdev and bipartite fallback versions.References
Reviewer guidance
kolibri.core.upgradeimports cleanly withoutValueError.AI usage
I used Antigravity / Gemini to locate where
kolibri.core.upgradefails during pytest startup and identify the regex mismatch innormalize_version_to_semver(). I reviewed the SemVer 2.0 specification andsemverlibrary constraints, implemented the fix to prevent trailing dot leakage and duplicate.devfragments, wrote regression tests inkolibri/utils/tests/test_version.py, and verified the entire test suite runs without errors.