Skip to content

Ensure no extraction conflicts and unpack all Dart SDK archive artifacts - #192447

Open
bkonyi wants to merge 2 commits into
flutter:masterfrom
bkonyi:investigation/issue-132702
Open

bkonyi wants to merge 2 commits into
flutter:masterfrom
bkonyi:investigation/issue-132702

Conversation

@bkonyi

@bkonyi bkonyi commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #132702

Summary

When downloading and extracting the Dart SDK archive during Flutter bootstrap/upgrade (update_dart_sdk.sh and update_dart_sdk.ps1), archives containing files outside dart-sdk/ (e.g. LICENSE.dart_sdk_archive.md or future metadata/artifacts) previously caused extraction issues:

  1. Extraction prompt hangs on Windows:
    In #132592, adding LICENSE.dart_sdk_archive.md to the archive root caused 7-Zip (7z/7za) to prompt interactively on stdout/stdin when overwriting an existing file, which PowerShell hides from background processes, resulting in an indefinite hang.
    Workaround in #132777 only targeted the single license file without addressing the general overwrite conflict during extraction.

  2. Discarded archive artifacts:
    Both update_dart_sdk.sh and update_dart_sdk.ps1 previously hardcoded moving only LICENSE.dart_sdk_archive.md. Any other top-level files or directories in the Dart SDK archive were discarded during cleanup of the temporary extraction directory.

Solution

  • bin/internal/update_dart_sdk.ps1:
    • Add -aoa overwrite switch to 7z and 7za.
    • Add -Force switch to Microsoft.PowerShell.Archive\Expand-Archive.
    • Add flag 16 (FOF_NOCONFIRMATION) to COM copyhere($item, 16).
    • Replace hardcoded license logic with a generic traversal of all extracted files and directories, safely moving them into bin/cache/.
  • bin/internal/update_dart_sdk.sh:
    • Replace hardcoded license logic with a generic loop over all items in $DART_SDK_PATH_TEMP/*, safely removing preexisting destination items and moving extracted artifacts into bin/cache/.

Tests

  • Added automated test in dev/tools/test/update_dart_sdk_test.dart testing mock SDK download, multi-file/directory extraction, version upgrades, and non-interactive overwrite handling.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

Pass overwrite flags (`-aoa` to 7-Zip, `-Force` to Expand-Archive, and 16 to COM copyhere) in `update_dart_sdk.ps1` to prevent interactive overwrite confirmation prompts when expanding downloaded SDK archives on Windows.

Generalize post-extraction artifact movement in both `update_dart_sdk.sh` and `update_dart_sdk.ps1` to iterate over all files and directories extracted into the temporary directory and move them into `bin/cache/`, removing hardcoded single-file assumptions.

Add comprehensive automated test `dev/tools/test/update_dart_sdk_test.dart`.

Fixes flutter#132702
@bkonyi
bkonyi marked this pull request as ready for review September 8, 2026 19:57
@bkonyi
bkonyi requested a review from jtmcdole as a code owner September 8, 2026 19:57
@bkonyi bkonyi added the CICD Run CI/CD label Sep 8, 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 updates the Dart SDK update scripts (update_dart_sdk.ps1 and update_dart_sdk.sh) to move all extracted files and directories from the temporary directory to the cache directory, and introduces a new integration test suite in update_dart_sdk_test.dart. The review feedback highlights a compilation error in the new test file where FileSystemEntity.basename is accessed incorrectly, and suggests using LineSplitter.split for robust line splitting. Additionally, the feedback recommends specifying an execution policy when invoking PowerShell on Windows, and improving error handling in both the PowerShell and Shell update scripts to prevent silent failures during file operations.

Comment thread dev/tools/test/update_dart_sdk_test.dart
Comment thread dev/tools/test/update_dart_sdk_test.dart
Comment on lines +141 to +143
if (Test-Path $dest) {
Remove-Item $dest -Recurse -Force -ErrorAction SilentlyContinue
}

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.

medium

Using -ErrorAction SilentlyContinue when removing the destination path is risky. If the deletion fails (e.g., due to a file lock or permission issue), the subsequent Move-Item will either fail with a confusing error or silently move the directory inside the existing one, leading to a corrupted cache. It is safer to use -ErrorAction Stop to ensure any deletion failure is caught and handled.

        if (Test-Path $dest) {
            Remove-Item $dest -Recurse -Force -ErrorAction Stop
        }

Comment thread bin/internal/update_dart_sdk.sh
Comment thread dev/tools/test/update_dart_sdk_test.dart
Check the exit code of `mv` when moving extracted items to `bin/cache/` in `update_dart_sdk.sh` to prevent continuing on failure.

Use `LineSplitter.split()` in `update_dart_sdk_test.dart` to robustly split process output lines across all platforms.
@Piinks Piinks added the team-tool Owned by Flutter Tool team label Sep 9, 2026
@flutter-dashboard

Copy link
Copy Markdown

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD team-tool Owned by Flutter Tool team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure there are no conflicts while the Flutter SDK unzips engine artifacts

2 participants