Skip to content

Chore/upgrade/packageinfoplus and win32#6945

Draft
cadivus wants to merge 16 commits intomainfrom
chore/upgrade/packageinfoplus
Draft

Chore/upgrade/packageinfoplus and win32#6945
cadivus wants to merge 16 commits intomainfrom
chore/upgrade/packageinfoplus

Conversation

@cadivus
Copy link
Copy Markdown
Member

@cadivus cadivus commented Apr 24, 2026

Upgrade package_info_plus 9.0.0 → 10.1.0

package_info_plus 10.x requires win32 ^6.0.1 → cascading bumps.

Dep bumps

Package Old New
package_info_plus ^9.0.0 ^10.1.0
win32 ^5.14.0 ^6.0.1
win32_registry ^2.1.0 ^3.0.3
device_info_plus ^12.0.0 ^13.1.0
Dart ^3.9.0 ^3.10.0
Flutter >=3.35.0 >=3.38.1

All lower bounds are the true minimum — versions below these require Dart ≥3.11.

Required follow-ups

  • win32 5→6 FFI migration in 3 files (utils.dart, data_protection.dart, asf_device_info_collector.windows.dart) — Win32Result<T>, CryptProtectData 7→6 args, GetVersionExRtlGetVersion, registry API, etc. Migration guide.
  • --force-jit for build_runner — Dart 3.10 + native-assets AOT regression (dart-lang/build#4343). Revert when Dart 3.11 is the floor.
  • file_pickerfile_selector in amplify_storage_s3/examplefile_picker hard-pins win32 ^5.9.0, no win32 6.x version exists.
  • CMake native-assets install block added to 9 example apps × {windows, linux} — fixes error code 126 DLL-not-found at runtime (flutter/flutter#165463).
  • CryptProtectData/CryptUnprotectData: check BOOL return before GetLastError per MSDN (pre-existing latent bug, fixed since we were in the file).

Behavior change

Cognito ASF's Windows fingerprint now reports the real OS version (Windows/10.0.22631) instead of the AppCompat-shimmed Windows/6.2.9200. RtlGetVersion doesn't lie.

@cadivus cadivus changed the title Chore/upgrade/packageinfoplus Chore/upgrade/packageinfoplus and win32 Apr 24, 2026
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.22%. Comparing base (3c30a20) to head (0ff04fe).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6945   +/-   ##
=======================================
  Coverage   43.22%   43.22%           
=======================================
  Files          99       99           
  Lines        7769     7769           
  Branches     3400     3400           
=======================================
  Hits         3358     3358           
  Misses       4411     4411           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

cadivus added 10 commits April 24, 2026 18:36
…ibility

Bumps transitive win32 dependency from ^5.14.0 to ^6.1.0 required by
package_info_plus 10.x and device_info_plus 13.x. This is a breaking
change in win32 (typed handles, Win32Result<T> for SetLastError APIs,
CryptProtectData signature change, Registry API redesign).

Also bumps:
- win32_registry from ^2.1.0 to ^3.0.3 (compatible with win32 6.x)
- device_info_plus from ^12.0.0 to ^13.1.0 (win32 6.x compat)

Migrates ASF device info collector and secure storage DPAPI wrapper:
- GetModuleFileName / GetFileVersionInfo*: now return Win32Result<T>
- VerQueryValue: now returns bool directly
- CryptProtectData/CryptUnprotectData: new 6-arg signature
- Replace GetVersionEx with RtlGetVersion
- Replace Registry.openPath(RegistryHive.localMachine, ...) with
  LOCAL_MACHINE.open(...) and getString()
- Replace WindowsException(HRESULT_FROM_WIN32(GetLastError())) with
  WindowsException(WIN32_ERROR(code).toHRESULT())
- IsWindows10OrGreater/IsWindowsServer now return bool directly
- Remove deprecated TEXT() usage; use arena.pcwstr() helpers
…r package_info_plus 10.x

package_info_plus 10.1.0, device_info_plus 13.1.0 and win32 6.1.0
all require Dart >=3.10.0 / Flutter >=3.38.1. Bumps the monorepo-wide
SDK floor to match.

Version mapping (per flutter_infra_release/releases_linux.json):
  Flutter 3.38.1 → Dart 3.10.0 (2025-11-13, first stable with Dart 3.10)

Updates `environment.sdk` from ^3.9.0 to ^3.10.0 and
`environment.flutter` from >=3.35.0 to >=3.38.1 in every
pubspec.yaml across the monorepo (94 files).
Aligns CI matrix minimum-version entries with the new monorepo SDK
floor (Dart 3.10.0, Flutter 3.38.1) required by package_info_plus 10.x,
device_info_plus 13.x, and win32 6.x.

Files updated:
- .github/workflows/actions.yaml: setup-dart sdk 3.9.0 -> 3.10.0
- .github/workflows/amplify_canaries.yaml: flutter-version 3.35.0 -> 3.38.1
- .github/workflows/flutter_vm.yaml: flutter-version 3.35.0 -> 3.38.1
- .github/workflows/dart_dart2js.yaml: sdk 3.9.0 -> 3.10.0
- .github/workflows/dart_ddc.yaml: sdk 3.9.0 -> 3.10.0
- .github/workflows/dart_vm.yaml: sdk 3.9.0 -> 3.10.0
Dart 3.10 introduced stricter checks in `dart compile exe` that refuse to
compile when the package graph contains native-assets build hooks
(e.g. `win32 6.x`, `sqlite3`). `build_runner` 2.14+ defaults to AOT
compilation and therefore fails on Dart 3.10 during `aft bootstrap` with:

    'dart compile' does not support build hooks, use 'dart build' instead.
    Failed to compile build script.

The fix ships in Dart 3.11+, but since the minimum supported Flutter for
this repo is 3.38.1 (Dart 3.10.0), force JIT compilation everywhere we
invoke build_runner programmatically. AOT will resume being the default
once the minimum SDK moves to Dart 3.11.

See:
- dart-lang/build#4343
- dart-lang/sdk#62593

Modified:
- `aft bootstrap` / `aft publish` / `aft version-bump` (publish_command.dart)
- `aft generate goldens` (generate_goldens_command.dart)
- `aft generate sdk` (generate_sdk_command.dart)
- `smithy_codegen` CLI (smithy_codegen.dart)
CI steps that invoke `dart run build_runner build` directly (outside of
aft) also need to opt out of AOT on Dart 3.10 to work around the
`dart compile exe` + build hooks regression (see prior commit and
dart-lang/build#4343).

Workflows touched:
- dart_dart2js.yaml (release build + tests)
- dart_ddc.yaml (web tests)
- composite_actions/install_dependencies (partial aft bootstrap)
`FilePicker.pickFiles(...)` was deprecated and then removed in favor of
`FilePicker.platform.pickFiles(...)` in `file_picker` 5.x+. With the
example's `file_picker: any` constraint resolving to the latest release,
the static call now emits:

    error - Instance member 'pickFiles' can't be accessed using static access
            - static_access_to_instance_member

Switch to the instance-based API, matching the usage already documented in
`packages/aws_common/lib/src/io/aws_file.dart`.
…ve-assets hook

The win32 6.x package uses Dart hooks to download a prebuilt
'win32_windows_x64.dll' at build time. 'flutter test integration_test/'
alone does not always invoke the native-assets build hook, so the DLL
was missing at runtime with:

  Failed to load dynamic library 'win32_windows_x64.dll':
  The specified module could not be found. (error code: 126).

Run 'flutter build windows --debug' before the integration test so
the hook downloads and bundles the DLL, then the test harness can
load CryptProtectData_Wrapper from win32.

Refs: https://dart.dev/tools/hooks (Dart 3.10 hooks are stable)
The 'file_picker: any' constraint in the amplify_storage_s3 example
was resolving to 3.0.4 on Android CI because file_picker >=8.3.3
transitively requires win32 ^5.9.0, which conflicted with the
monorepo's win32 ^6.1.0 (needed for package_info_plus 10.x).

file_picker 3.0.4 is too old for modern AGP and fails with:
  A problem occurred configuring project ':file_picker'.
  > Namespace not specified. Specify a namespace in the module's
    build file.

Fix:
- Pin file_picker to ^11.0.0 (latest, static API restored).
- Add 'dependency_overrides: win32: ^6.1.0' so the file_picker
  constraint doesn't drag win32 back to 5.x.
- Update FilePicker.platform.pickFiles() -> FilePicker.pickFiles()
  since file_picker 11.x moved methods back to static.
@cadivus cadivus force-pushed the chore/upgrade/packageinfoplus branch 2 times, most recently from 5374892 to 18d25b3 Compare April 24, 2026 18:45
cadivus added 6 commits April 24, 2026 19:25
file_picker 11.x declares a hard `win32 ^5.9.0` dependency which
conflicts with the monorepo's win32 6.1.0 requirement (needed by
package_info_plus 10.x and device_info_plus 13.x). There is no
published version of file_picker that supports win32 6.x, so the
example previously relied on a `dependency_overrides: win32: ^6.1.0`
workaround that would fail to compile on Windows (file_picker's
Windows implementation uses APIs removed in win32 6.x: `TEXT()`,
`FileOpenDialog.createInstance()`, 2-arg `CoInitializeEx`, and the
old `IShellItem.getDisplayName` shape).

Replace file_picker with file_selector (the official Flutter-team
plugin). file_selector uses a native C++ Windows implementation
and has no Dart win32 dependency, eliminating the conflict and
removing the need for the dependency override. Only one call site
in main.dart was affected.

- Removes: file_picker ^11.0.0, dependency_overrides.win32
- Adds: file_selector ^1.1.0
- Migrates: FilePicker.pickFiles(type: FileType.image, withReadStream)
  to openFile(acceptedTypeGroups: [XTypeGroup(extensions/mimeTypes/UTIs)])
  and AWSFile.fromStream uses XFile.openRead() with an awaited
  XFile.length() for size

Generated plugin registrants (linux, macos, windows) are regenerated
accordingly.
…for file_selector

file_selector_macos requires the App Sandbox entitlement
`com.apple.security.files.user-selected.read-only` (or the
read-write variant) to read files picked by the user. Without it
the macOS file picker returns but opening the returned XFile for
reading fails with a sandbox violation.

Reference:
https://pub.dev/packages/file_selector_macos#entitlements

The example only reads a user-selected image for upload, so
read-only is sufficient.
Older Flutter projects (predating native-assets migration) are missing the
install block in windows/CMakeLists.txt and linux/CMakeLists.txt that copies
'${PROJECT_BUILD_DIR}native_assets/<platform>/' into ${INSTALL_BUNDLE_LIB_DIR}.

Without this block, 'flutter build windows' and 'flutter test -d windows'
successfully run the build hooks (win32 6.x downloads win32_windows_x64.dll
into build/native_assets/windows/), but the DLL is never staged next to the
test/runner executable. At runtime, Dart FFI tries to dlopen the DLL and
fails with:

  Failed to load dynamic library 'win32_windows_x64.dll':
  The specified module could not be found. (error code: 126)

This breaks the amplify_storage_s3_example Windows e2e tests because
amplify_secure_storage -> win32 6.x uses native-assets for CryptProtectData.

The two packages in the repo that were recently rebootstrapped from a newer
Flutter template (amplify_firehose and amplify_kinesis) already include the
correct block — we replicate it in the remaining nine example apps.

Ref: flutter/flutter#165463 (same root cause, same fix)
Ref: https://docs.flutter.dev/platform-integration/c-interop#native-assets
…-step

The pre-build step was an early workaround attempt before the real root cause
was found. flutter test -d windows already triggers the native-assets build
hook and CMake install phase — the true fix is the CMake install block added
in f8c420a that copies build/native_assets/windows/ into the runner bundle.

Evidence:
- Linux e2e has no equivalent pre-build step and passes on this PR
- Flutter's TestCommand uses the same artifact pipeline as flutter build
- Ref: flutter/flutter#165463

Restores .github/workflows/e2e_windows.yaml to byte-identical with main.
…rotectData

Per Microsoft docs, CryptProtectData/CryptUnprotectData return BOOL
(nonzero on success). The previous implementation only inspected
GetLastError() / ERROR_SUCCESS, which is undefined when the function
succeeds (the API may not clear last-error on success). This could
theoretically cause spurious failures on systems where a prior API
left a non-success error code in the thread's last-error slot.

Both this PR and main had this issue - fixing it here since we're
already touching the surrounding code for the win32 6.x migration
and want post-migration behavior to be at least as correct as
pre-migration.
win32 6.1.0 only changed the build hook (prebuilt binary download)
and introduced no new Dart APIs we depend on. The earlier 6.0.1 is
the true floor — it's the first version whose minimum Dart SDK
(^3.10.0) matches our monorepo floor (6.0.0 required ^3.11.0).

Allowing ^6.0.1 avoids forcing downstream consumers to upgrade to
win32 6.1.0 if they have other constraints. The resolver still
picks 6.1.0 in this repo since it's the latest satisfying ^6.0.1.

Other loosening attempts checked and rejected:
  - package_info_plus: 10.0.0 needs Dart ^3.11.0, so ^10.1.0 is true floor
  - device_info_plus:  13.0.0 needs Dart ^3.11.0, so ^13.1.0 is true floor
  - win32_registry:    3.0.0-3.0.2 need Dart ^3.11.0, so ^3.0.3 is true floor
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