Skip to content

fix(python): inherit pip indexes in build container - #5574

Merged
Jacob Viau (jviau) merged 2 commits into
mainfrom
u/jviau/fix-python-docker-pip-auth
Sep 1, 2026
Merged

Jacob Viau (jviau) merged 2 commits into
mainfrom
u/jviau/fix-python-docker-pip-auth

Conversation

@jviau

Copy link
Copy Markdown
Contributor

Summary

  • pass PIP_INDEX_URL and PIP_EXTRA_INDEX_URL by name to Python native-dependency containers
  • preserve authenticated package feed routing without exposing credential-bearing values in Docker command output
  • add focused tests for Docker run argument generation

Motivation

The core-tools.public Python E2E test Pack_Python_BuildNativeDeps_OnWindows_WorksAsExpected failed under network isolation because the containerized pip install contacted pypi.org directly. The host had been configured by PipAuthenticate, but those index variables were not inherited by the Docker container.

Validation

dotnet test test\Cli\Func.UnitTests\Azure.Functions.Cli.UnitTests.csproj --framework net10.0 --no-restore --filter FullyQualifiedName~DockerHelpersTests

Pass pip index environment variables by name when starting the native dependency container so authenticated feeds work without exposing credential-bearing values.
@jviau
Jacob Viau (jviau) requested a review from a team as a code owner August 27, 2026 16:44

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review Findings

Overall: Looks good β€” clean, well-tested change. A couple of observations:

1. --env argument quoting (low risk)

In GetDockerRunArguments, env var names are interpolated directly into args.Add($"--env {environmentVariable}"). Since only bare variable names (PIP_INDEX_URL, PIP_EXTRA_INDEX_URL) are passed by the current caller, this is safe today. But if a future caller passes a value containing spaces or shell metacharacters (e.g. VAR=hello world), the argument would be split by the docker CLI. Consider adding each as two separate list entries (args.Add("--env"); args.Add(environmentVariable);) β€” though this depends on how RunDockerCommand tokenizes the string. Not blocking.

2. dockerRunSetting branch doesn't get env vars

When dockerRunSetting is non-empty (PythonHelpers.cs line 514), the custom docker run command is used as-is β€” the PIP_* env vars won't be forwarded. This is pre-existing behavior, but worth a note in the PR description since users with custom docker run settings would need to add --env PIP_INDEX_URL --env PIP_EXTRA_INDEX_URL themselves.

3. Tests are solid βœ…

The two unit tests cover the happy path and the no-args path well. The extracted GetDockerRunArguments method is a nice improvement for testability.

No blocking issues found.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to update release notes?

@jviau
Jacob Viau (jviau) merged commit a773d0d into main Sep 1, 2026
42 checks passed
@jviau
Jacob Viau (jviau) deleted the u/jviau/fix-python-docker-pip-auth branch September 1, 2026 18:42
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.

4 participants