Skip to content

Fix ZipHelperTests CI failure by removing fragile directory traversal#4831

Merged
liliankasem merged 1 commit intomainfrom
liliankasem/unittest/ziphelperaccess
Mar 19, 2026
Merged

Fix ZipHelperTests CI failure by removing fragile directory traversal#4831
liliankasem merged 1 commit intomainfrom
liliankasem/unittest/ziphelperaccess

Conversation

@liliankasem
Copy link
Member

@liliankasem liliankasem commented Mar 19, 2026

Summary

Fixes ZipHelperTests.CreateZip_Succeeds failing on certain Windows CI agents with:

System.UnauthorizedAccessException: Access to the path 'C:\Users\cloudtest\Application Data' is denied.

Problem

The test located ZippedExe.csproj by walking up exactly 4 parent directories from the CWD, then doing a recursive GetFiles search from there. This approach had two issues:

  1. Fragile depth assumption — the 4-parent walk assumes a specific output directory depth (out/bin/Azure.Functions.Cli.UnitTests/debug/), which could break if the build layout changes.
  2. Unsafe recursive enumeration — searching from the repo root with SearchOption.AllDirectories traverses the entire directory tree, including protected Windows junction points (e.g., Application DataAppData\Roaming) that throw UnauthorizedAccessException.

Fix

Replaced both the hardcoded parent traversal and recursive search with:

  • Walk up to repo root reliably by searching for Azure.Functions.Cli.sln as a root marker — works regardless of output directory depth.
  • Use the known path directly (test/ZippedExe/) instead of recursively scanning — ZippedExe.csproj is always at a fixed location relative to the repo root.
  • Compute outPath from repo root instead of relative .. navigation from the csproj directory.

No recursive directory enumeration of unknown trees is performed anymore.

Changes

  • test/Cli/Func.UnitTests/HelperTests/ZipHelperTests.cs — refactored BuildAndCopyFileToZipAsync to find repo root deterministically

@liliankasem liliankasem requested a review from a team as a code owner March 19, 2026 19:04
@liliankasem liliankasem force-pushed the liliankasem/unittest/ziphelperaccess branch from d22a32d to 00f52bd Compare March 19, 2026 19:07
@liliankasem liliankasem changed the title Fix ZipHelperTests CI failure on Windows agents with protected junction points Fix ZipHelperTests CI failure by removing fragile directory traversal Mar 19, 2026
@liliankasem liliankasem merged commit 25df698 into main Mar 19, 2026
39 checks passed
@liliankasem liliankasem deleted the liliankasem/unittest/ziphelperaccess branch March 19, 2026 23:23
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