{"id":20132500,"url":"https://github.com/aherrmann/repro-bzlmod-module-extension-cycle","last_synced_at":"2026-03-07T01:03:23.991Z","repository":{"id":185564631,"uuid":"605624566","full_name":"aherrmann/repro-bzlmod-module-extension-cycle","owner":"aherrmann","description":null,"archived":false,"fork":false,"pushed_at":"2023-02-23T15:01:22.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-02T22:18:22.693Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aherrmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"open_collective":"bazel-rules-authors-sig"}},"created_at":"2023-02-23T14:57:43.000Z","updated_at":"2023-02-23T15:01:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"ace8f77b-ee6f-4b71-a2a5-eaa8b6173548","html_url":"https://github.com/aherrmann/repro-bzlmod-module-extension-cycle","commit_stats":null,"previous_names":["aherrmann/repro-bzlmod-module-extension-cycle"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aherrmann/repro-bzlmod-module-extension-cycle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Frepro-bzlmod-module-extension-cycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Frepro-bzlmod-module-extension-cycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Frepro-bzlmod-module-extension-cycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Frepro-bzlmod-module-extension-cycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aherrmann","download_url":"https://codeload.github.com/aherrmann/repro-bzlmod-module-extension-cycle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aherrmann%2Frepro-bzlmod-module-extension-cycle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30204452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T20:53:49.603Z","updated_at":"2026-03-07T01:03:23.961Z","avatar_url":"https://github.com/aherrmann.png","language":"Starlark","funding_links":["https://opencollective.com/bazel-rules-authors-sig"],"categories":[],"sub_categories":[],"readme":"# Undetected cyclic dependency between module extensions\n\nThis repository illustrates an issue where Bazel does not detect a cyclic\ndependency between imported module extensions and instead silently disregards\ntags on the affected extension.\n\n## Expected behavior\n\nYou can observe the expected behavior with the following command:\n\n```\n$ (cd module_b; bazel fetch @extension_2//:defs.bzl)\nDEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_b TAG module_b_tag_1\nDEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_b TAG module_b_tag_2\nDEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_a TAG module_a_tag_1\nDEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_a TAG module_a_tag_2\nDEBUG: .../module_a~override/extension_2.bzl:5:10: extension_2 found hello from extension_1, 4 tags\n```\n\nNote that 4 tags of `extension_1` are reported.\n\n## Faulty behavior\n\nYou can observe the faulty behavior by changing the extension imports in\n`module_b` as follows:\n\n```diff\ndiff --git a/module_b/MODULE.bazel b/module_b/MODULE.bazel\nindex 16a8f90..8f57311 100644\n--- a/module_b/MODULE.bazel\n+++ b/module_b/MODULE.bazel\n@@ -3,15 +3,15 @@ module(name = \"module_b\")\n bazel_dep(name = \"module_a\")\n local_path_override(module_name = \"module_a\", path = \"../module_a\")\n\n-# extension_1 = use_extension(\"@module_a//:extensions.bzl\", \"extension_1\")\n-# extension_2 = use_extension(\"@module_a//:extensions.bzl\", \"extension_2\")\n+extension_1 = use_extension(\"@module_a//:extensions.bzl\", \"extension_1\")\n+extension_2 = use_extension(\"@module_a//:extensions.bzl\", \"extension_2\")\n # $ (cd module_b; bazel fetch @extension_2//:defs.bzl)\n # DEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_a TAG module_a_tag_1\n # DEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_a TAG module_a_tag_2\n # DEBUG: .../module_a~override/extension_2.bzl:5:10: extension_2 found hello from extension_1, 2 tags\n\n-extension_1 = use_extension(\"@module_a//:extension_1.bzl\", \"extension_1\")\n-extension_2 = use_extension(\"@module_a//:extension_2.bzl\", \"extension_2\")\n+# extension_1 = use_extension(\"@module_a//:extension_1.bzl\", \"extension_1\")\n+# extension_2 = use_extension(\"@module_a//:extension_2.bzl\", \"extension_2\")\n # $ (cd module_b; bazel fetch @extension_2//:defs.bzl)\n # DEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_b TAG module_b_tag_1\n # DEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_b TAG module_b_tag_2\n```\n\nAnd then executing the following command:\n\n```\n$ (cd module_b; bazel fetch @extension_2//:defs.bzl)\nDEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_a TAG module_a_tag_1\nDEBUG: .../module_a~override/extension_1.bzl:7:18: MODULE module_a TAG module_a_tag_2\nDEBUG: .../module_a~override/extension_2.bzl:5:10: extension_2 found hello from extension_1, 2 tags\n```\n\nNote that no only 2 tags of `extension_1` are reported. The tags defined in\n`module_b` are lost.\n\n## For reference\n\nBazel does detect the cyclic dependency from the context of `module_a` which\ndefines the module extensions `extension_1` and `extension_2`.\n\nFirst modify the imports in `module_a` as follows:\n\n```diff\ndiff --git a/module_a/MODULE.bazel b/module_a/MODULE.bazel\nindex 5ff4cb7..11259b0 100644\n--- a/module_a/MODULE.bazel\n+++ b/module_a/MODULE.bazel\n@@ -1,6 +1,6 @@\n module(name = \"module_a\")\n\n-# extension_1 = use_extension(\"//:extensions.bzl\", \"extension_1\")\n+extension_1 = use_extension(\"//:extensions.bzl\", \"extension_1\")\n # ```\n # $ (cd module_a; bazel fetch @extension_1//:defs.bzl)\n # ERROR: Circular definition of repositories generated by module extensions and/or .bzl files:\n@@ -13,7 +13,7 @@ module(name = \"module_a\")\n # ERROR: cycles detected during target parsing\n # ```\n\n-extension_1 = use_extension(\"//:extension_1.bzl\", \"extension_1\")\n+# extension_1 = use_extension(\"//:extension_1.bzl\", \"extension_1\")\n\n extension_1.tag(name = \"module_a_tag_1\")\n extension_1.tag(name = \"module_a_tag_2\")\n```\n\nThen execute the following command to trigger the error:\n\n```\n$ (cd module_a; bazel fetch @extension_1//:defs.bzl)\nERROR: Circular definition of repositories generated by module extensions and/or .bzl files:\n.-\u003e @_main~extension_1~extension_1\n|   extension 'extension_1' defined in //:extensions.bzl\n|   //:extensions.bzl\n|   //:extension_2.bzl\n|   @_main~extension_1~extension_1//:defs.bzl\n`-- @_main~extension_1~extension_1\nERROR: cycles detected during target parsing\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faherrmann%2Frepro-bzlmod-module-extension-cycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faherrmann%2Frepro-bzlmod-module-extension-cycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faherrmann%2Frepro-bzlmod-module-extension-cycle/lists"}