Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
prompt the user to select which target framework to use for the Dockerfile.
- Enhanced dotnet installation discovery by adopting the same `Muxer` logic used by the .NET SDK itself (#4732)
- Update .NET templates package version to 4.0.5337 (#4728)
- Fix `func pack --build-native-deps` failure on Windows for Python 3.13+ (#4742)
5 changes: 3 additions & 2 deletions src/Cli/func/Helpers/PythonHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,11 @@ private static async Task<DockerImageInfo> ChoosePythonBuildEnvImage()
{
// Setup image tag and content
string imageContent = image;
image = $"azure-functions/python:4-python{workerInfo.Major}.{workerInfo.Minor}-buildenv";
string dockerfileName = $"4-python{workerInfo.Major}{workerInfo.Minor}-buildenv";
image = $"azure-functions/python:{dockerfileName}";

// Prepare temporary directory for docker build context
string tempDockerfileDirecotry = Path.Combine(Path.GetTempPath(), $"{image}-docker");
string tempDockerfileDirecotry = Path.Combine(Path.GetTempPath(), $"{dockerfileName}");
FileSystemHelpers.EnsureDirectory(tempDockerfileDirecotry);
string tempDockerfile = Path.Combine(tempDockerfileDirecotry, "Dockerfile");

Expand Down
23 changes: 23 additions & 0 deletions test/Cli/Func.UnitTests/HelperTests/PythonHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,29 @@ public void AssertPythonVersion(string pythonVersion, bool expectException)
Assert.Throws<CliException>(() => PythonHelpers.AssertPythonVersion(worker));
}
}

[Theory]
[InlineData(3, 10)]
[InlineData(3, 11)]
[InlineData(3, 12)]
[InlineData(3, 13)]
[InlineData(3, 14)]
public void DockerfileNameShouldNotContainInvalidCharacters(int major, int minor)
{
// Verify the dockerfile name format matches what's used in ChoosePythonBuildEnvImage
// The format should be "4-python{major}{minor}-buildenv" with no colons or other invalid chars
string dockerfileName = $"4-python{major}{minor}-buildenv";

// Ensure no colons (invalid on Windows file paths)
Assert.DoesNotContain(":", dockerfileName);

// Ensure no other invalid Windows path characters
char[] invalidChars = Path.GetInvalidFileNameChars();
Assert.DoesNotContain(dockerfileName, c => invalidChars.Contains(c));

// Verify expected format
Assert.Matches(@"^4-python\d+-buildenv$", dockerfileName);
}
}

public sealed class SkipIfPythonNonExistFact : FactAttribute
Expand Down