Skip to content

[release/13.2] Fix Playwright CLI provenance verification for tag format change#16134

Merged
joperezr merged 2 commits intorelease/13.2from
cherry-pick/playwright-provenance-fix
Apr 14, 2026
Merged

[release/13.2] Fix Playwright CLI provenance verification for tag format change#16134
joperezr merged 2 commits intorelease/13.2from
cherry-pick/playwright-provenance-fix

Conversation

@mitchdenny
Copy link
Copy Markdown
Member

Description

Cherry-pick of #16087 from main onto release/13.2 for the next 13.2.x servicing release.

Problem: @playwright/cli 0.1.7 changed their git tag naming convention from v0.1.7 to 0.1.7 (dropped the v prefix). This caused Aspire's provenance verification to fail with WorkflowRefMismatch when installing the Playwright CLI agent skill.

Fix: Accept both tag formats (with and without v prefix) in the validateWorkflowRef callback for forward/backward compatibility.

Cherry-pick conflict resolution: The unit test for the new tag format validation was adapted to use the release/13.2 branch's InstallAsync(AgentEnvironmentScanContext, CancellationToken) API signature (which returns bool) instead of main's tuple-returning API with explicit temp directory management.

Validation: Merge conflict resolved by adapting the new InstallAsync_WorkflowRefValidator_AcceptsBothTagFormats test to match the release branch's CreateTestContext() pattern used by all other tests in the file.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

Copilot AI review requested due to automatic review settings April 13, 2026 23:43
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16134

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16134"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Cherry-pick onto release/13.2 to fix Playwright CLI (@playwright/cli) provenance verification failures caused by an upstream git tag format change (dropping the v prefix), and to add regression coverage.

Changes:

  • Update PlaywrightCliInstaller provenance validateWorkflowRef logic to accept both refs/tags/{version} and refs/tags/v{version}.
  • Add a unit test that captures the workflow-ref validator and verifies both tag formats are accepted.
  • Add an end-to-end test intended to validate aspire new → agent init → Playwright CLI install completes without provenance errors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Aspire.Cli/Agents/Playwright/PlaywrightCliInstaller.cs Relax workflow-ref tag matching to accept both tag naming conventions.
tests/Aspire.Cli.Tests/Agents/PlaywrightCliInstallerTests.cs Adds a unit test to validate both tag formats via the captured validator callback.
tests/Aspire.Cli.EndToEnd.Tests/NewWithAgentInitTests.cs Introduces an E2E regression test for the aspire new + agent init Playwright install flow.

Comment on lines +346 to +370
[Fact]
public async Task InstallAsync_WorkflowRefValidator_AcceptsBothTagFormats()
{
var version = SemVersion.Parse("0.1.7", SemVersionStyles.Strict);
var npmRunner = new TestNpmRunner
{
ResolveResult = new NpmPackageInfo { Version = version, Integrity = "sha512-abc123" }
};
var provenanceChecker = new TestNpmProvenanceChecker();
var playwrightRunner = new TestPlaywrightCliRunner();
var installer = new PlaywrightCliInstaller(npmRunner, provenanceChecker, playwrightRunner, new TestInteractionService(), new ConfigurationBuilder().Build(), NullLogger<PlaywrightCliInstaller>.Instance);

await installer.InstallAsync(CreateTestContext(), CancellationToken.None);

Assert.True(provenanceChecker.ProvenanceCalled);
Assert.NotNull(provenanceChecker.CapturedValidateWorkflowRef);

// Accept tags without 'v' prefix (0.1.7+)
Assert.True(WorkflowRefInfo.TryParse($"refs/tags/{version}", out var refWithout));
Assert.True(provenanceChecker.CapturedValidateWorkflowRef(refWithout!));

// Accept tags with 'v' prefix (pre-0.1.7)
Assert.True(WorkflowRefInfo.TryParse($"refs/tags/v{version}", out var refWith));
Assert.True(provenanceChecker.CapturedValidateWorkflowRef(refWith!));
}
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

This new test calls InstallAsync but doesn't assert the returned result, and with the current TestNpmRunner/TestPlaywrightCliRunner defaults the install will return false (PackResult is null and InstallSkillsResult defaults to false). Consider either asserting the expected false result explicitly (to make the intent clear), or fully wiring the runner fakes (PackResult + valid integrity + InstallSkillsResult) so the install path succeeds while still capturing the workflow ref validator.

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +58
// Create .claude folder so agent init detects a Claude Code environment.
// This needs to exist in the workspace root before aspire new creates the project
// because agent init chains after project creation and looks for environment markers.
await auto.TypeAsync("mkdir -p .claude");
await auto.EnterAsync();
await auto.WaitForSuccessPromptAsync(counter);

// Run aspire new with the Starter template, going through all prompts manually
// so we can ACCEPT the agent init prompt instead of declining it.
await auto.TypeAsync("aspire new");
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

The test setup creates a .claude folder in the workspace root before running aspire new, but NewCommand chains agent init using the template output directory as the workspace root. This means the Claude Code scanner can end up detecting the parent .claude and writing config/skill files outside the newly created project directory, making the test less representative and potentially fragile if scanner boundary behavior changes.

Suggested change
// Create .claude folder so agent init detects a Claude Code environment.
// This needs to exist in the workspace root before aspire new creates the project
// because agent init chains after project creation and looks for environment markers.
await auto.TypeAsync("mkdir -p .claude");
await auto.EnterAsync();
await auto.WaitForSuccessPromptAsync(counter);
// Run aspire new with the Starter template, going through all prompts manually
// so we can ACCEPT the agent init prompt instead of declining it.
await auto.TypeAsync("aspire new");
// Create a dedicated project directory and place .claude inside it so agent init
// detects the Claude Code environment from the actual template output directory.
await auto.TypeAsync("mkdir -p agent-init-project && cd agent-init-project && mkdir -p .claude");
await auto.EnterAsync();
await auto.WaitForSuccessPromptAsync(counter);
// Run aspire new in the current directory, going through all prompts manually
// so we can ACCEPT the agent init prompt instead of declining it.
await auto.TypeAsync("aspire new .");

Copilot uses AI. Check for mistakes.
Comment on lines +118 to +136
// Agent init: skill location - select Claude Code
await auto.WaitUntilAsync(
s => s.ContainsText("skill files be installed"),
timeout: TimeSpan.FromSeconds(60),
description: "skill location prompt");
await auto.TypeAsync(" "); // Toggle off default Standard location
await auto.DownAsync();
await auto.TypeAsync(" "); // Toggle on Claude Code location
await auto.EnterAsync();

// Agent init: skill selection - toggle on Playwright CLI
await auto.WaitUntilAsync(
s => s.ContainsText("skills should be installed"),
timeout: TimeSpan.FromSeconds(30),
description: "skill selection prompt");
await auto.DownAsync();
await auto.TypeAsync(" "); // Toggle on Playwright CLI
await auto.EnterAsync();

Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

This E2E flow waits for prompt text like "skill files be installed" and "skills should be installed", but those strings don't appear in the current CLI resources/agent init command flow (agent init uses a single selection prompt like "What would you like to configure?"). As written, these waits are likely to time out/hang; consider matching the actual prompt text and selecting the relevant option(s) (e.g., the Playwright CLI install choice) based on the current AgentInitCommand output.

Suggested change
// Agent init: skill location - select Claude Code
await auto.WaitUntilAsync(
s => s.ContainsText("skill files be installed"),
timeout: TimeSpan.FromSeconds(60),
description: "skill location prompt");
await auto.TypeAsync(" "); // Toggle off default Standard location
await auto.DownAsync();
await auto.TypeAsync(" "); // Toggle on Claude Code location
await auto.EnterAsync();
// Agent init: skill selection - toggle on Playwright CLI
await auto.WaitUntilAsync(
s => s.ContainsText("skills should be installed"),
timeout: TimeSpan.FromSeconds(30),
description: "skill selection prompt");
await auto.DownAsync();
await auto.TypeAsync(" "); // Toggle on Playwright CLI
await auto.EnterAsync();
// Agent init: select the Playwright CLI configuration option from the current menu-based flow.
await auto.WaitUntilAsync(
s => s.ContainsText("What would you like to configure?") && s.ContainsText("Playwright CLI"),
timeout: TimeSpan.FromSeconds(60),
description: "agent init configuration prompt");
await auto.DownAsync();
await auto.EnterAsync();

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@JamesNK JamesNK left a comment

Choose a reason for hiding this comment

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

1 suggestion: missing negative assertions on the provenance validation callback test.

)

* Fix Playwright CLI provenance verification for tag format change

@playwright/cli 0.1.7 changed their git tag naming convention from
'v0.1.7' to '0.1.7' (dropped the 'v' prefix). This caused our
provenance verification to fail with WorkflowRefMismatch.

- Accept both tag formats (with and without 'v' prefix) in the
  validateWorkflowRef callback for forward/backward compatibility
- Add test verifying both tag formats pass validation

Co-authored-by: Copilot <[email protected]>

* Add E2E test for aspire new with agent init and Playwright install

Exercises the full aspire new → agent init → Playwright CLI install
flow end-to-end, verifying no provenance verification errors appear.
This is the primary regression test for tag format changes in upstream
@playwright/cli releases.

The test accepts the agent init prompt (instead of declining), selects
Playwright CLI during skill selection, and fails fast if a provenance
verification error is detected during npm package installation.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
@mitchdenny mitchdenny force-pushed the cherry-pick/playwright-provenance-fix branch from 16c59a8 to 714f998 Compare April 14, 2026 06:14
Verify the provenance validator rejects wrong versions and branch refs,
not just that it accepts the expected tag formats.

Addresses review feedback from @JamesNK.

Co-authored-by: Copilot <[email protected]>
@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 53 recordings uploaded (commit 733b9f5)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #24384964911

@joperezr joperezr merged commit 4280adc into release/13.2 Apr 14, 2026
755 of 761 checks passed
@github-actions github-actions bot added this to the 13.2.x milestone Apr 15, 2026
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