Skip to content

fix(pypi): respect empty envsubst expansion in experimental_index_url#3828

Merged
rickeylev merged 5 commits into
bazel-contrib:mainfrom
kriscfoster:patch-1
Jun 19, 2026
Merged

fix(pypi): respect empty envsubst expansion in experimental_index_url#3828
rickeylev merged 5 commits into
bazel-contrib:mainfrom
kriscfoster:patch-1

Conversation

@kriscfoster

@kriscfoster kriscfoster commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Resolve pip.parse(experimental_index_url = ...) through envsubst
before checking whether the experimental index-url code path should be
enabled.

Previously, an unsubstituted template like
$RULES_PYTHON_PIP_INDEX_URL is a non-empty string and therefore
truthy, so _set_get_index_urls enabled the experimental index-url
mode even when the env var was unset or expanded to empty.

With this change, the value is expanded first (using pip_attr.envsubst
and module_ctx.os.environ.get) and the truthiness check runs against
the resolved string, matching the behavior users expect when they gate
the index URL on an env var.

@kriscfoster kriscfoster changed the title Patch 1 fix(pypi): respect empty envsubst expansion in experimental_index_url Jun 17, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request integrates envsubst into hub_builder.bzl to resolve the experimental index URL, allowing environment variables to be substituted properly. It also adds corresponding regression tests. A critical issue was identified where module_ctx does not have a getenv method (it should be module_ctx.os.environ.get), and pip_attr.experimental_index_url could be None, which would cause a crash in envsubst.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/private/pypi/hub_builder.bzl

@rickeylev rickeylev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@rickeylev rickeylev enabled auto-merge June 19, 2026 16:58
@rickeylev rickeylev added this pull request to the merge queue Jun 19, 2026
Merged via the queue into bazel-contrib:main with commit fe24f8c Jun 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants