Fix patch generation for module() calls missing version or using 0.0.0#329
Draft
Fix patch generation for module() calls missing version or using 0.0.0#329
Conversation
Co-authored-by: AlexanderLanin <5074553+AlexanderLanin@users.noreply.github.com>
…0.0.0 version Co-authored-by: AlexanderLanin <5074553+AlexanderLanin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix bug in patch functionality
Fix patch generation for module() calls missing version or using 0.0.0
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related bugs caused the patch generator to produce wrong or crashing results when a
module()call omittedversion=/compatibility_level=, or when the release version was0.0.0.Root Causes
Wrong attribute patched (PR #326 regression)
parse_MODULE_file_contentused a globalversion=regex that matched the first occurrence in the file. Whenmodule()had noversion=attribute, the regex hit abazel_dep()version instead — producing a patch that rewrote the wrong line:AssertionErroronNonecomparisonVersion.__eq__assertedisinstance(other, Version), crashing whenmod_file.version is Nonewas compared against a releaseVersion.Spurious patch for
0.0.0with nocompatibility_levelBazel defaults
compatibility_levelto0. When a module omitted it and the release had major version0,0 == NoneevaluatedFalse, triggering an unnecessary (and potentially empty) patch.Changes
version.py—Version.__eq__returnsNotImplementedfor non-Versionoperands instead of asserting.bazel_wrapper.py—parse_MODULE_file_content— Scopesversion=andcompatibility_level=extraction to themodule(…)call only (DOTALL for multiline support).bazel_wrapper.py—_create_patch_for_module_version_if_mismatch— Rewritten to:version = "x.y.z"tomodule()when absent, rather than replacing an unrelated attribute.compatibility_level = Nwhen absent and release major > 0.compatibility_levelas0(Bazel default) when deciding whether a patch is needed.tests/conftest.py—make_update_infoaccepts an optionalmodule_contentoverride for custom fixture content.Version.__eq__withNone, parse scoping (ignoringbazel_depversions, multiline calls, zero version), and all new patch scenarios (missing version with 0.x.y release, missing version with major > 0,0.0.0with nocompatibility_level).Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.