Skip to content

fix: disable Chromium sandbox for playwright-cli mode in CI containers#48102

Merged
pelikhan merged 7 commits into
mainfrom
copilot/fix-chrome-sandbox-issue
Jul 26, 2026
Merged

fix: disable Chromium sandbox for playwright-cli mode in CI containers#48102
pelikhan merged 7 commits into
mainfrom
copilot/fix-chrome-sandbox-issue

Conversation

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

playwright: mode: cli workflows fail with "Playwright can't run in this sandbox environment" because GitHub Actions runners are containerised environments where kernel namespace sandboxing is unavailable. Docker/MCP mode already uses --no-sandbox; CLI mode had no equivalent.

Changes

  • pkg/workflow/playwright_cli.go — Adds a "Configure Playwright CLI sandbox" install step that writes PLAYWRIGHT_MCP_SANDBOX=false to $GITHUB_ENV, making it available to all subsequent steps (including the AWF agent step via --env-all):

    - name: Configure Playwright CLI sandbox
      run: echo 'PLAYWRIGHT_MCP_SANDBOX=false' >> "$GITHUB_ENV"
  • pkg/workflow/playwright_cli_test.go — Updates assertion from 2 → 3 expected steps; adds assertion for the new sandbox step.

  • *.lock.yml — Recompiled all affected workflows.


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 10.9 AIC · ⌖ 8.52 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14 AIC · ⌖ 8.18 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 23.1 AIC · ⌖ 6.65 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.5 AIC · ⌖ 7.28 AIC · ⊞ 7.1K ·
Comment /souschef to run again


Generated by 👨‍🍳 PR Sous Chef · gpt54 · 28.5 AIC · ⌖ 13 AIC · ⊞ 7.1K ·
Comment /souschef to run again


run: https://github.com/github/gh-aw/actions/runs/30207935610

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 23.3 AIC · ⌖ 7.77 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Set PLAYWRIGHT_MCP_SANDBOX=false via $GITHUB_ENV so that all subsequent
steps (including the agent step) have the sandbox disabled. This mirrors
the --no-sandbox flag already used in Docker/MCP mode and fixes the
'Playwright can't run in this sandbox environment' error reported in #48082.

The @playwright/cli package reads PLAYWRIGHT_MCP_SANDBOX to control
whether to enable the Chromium process sandbox. GitHub Actions runners
are containerised environments where namespace-based sandboxing is
unavailable, causing playwright-cli to abort. Writing this variable to
$GITHUB_ENV ensures it is available for all job steps that follow,
including the AWF-sandboxed agent step (--env-all propagates it).

Fixes #48082

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

Copy link
Copy Markdown
Collaborator

@copilot set this variable on the job in the generated code, not through a step

Copilot AI and others added 2 commits July 26, 2026 03:36
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot set this variable on the job in the generated code, not through a step

Done — moved PLAYWRIGHT_MCP_SANDBOX=false into buildMainJobEnv as a job-level env: entry (removing the dedicated step). The generated YAML now renders it alongside other job env vars like GH_AW_WORKFLOW_ID_SANITIZED. Commit: fix: set PLAYWRIGHT_MCP_SANDBOX=false at job-level env instead of a step

@pelikhan
pelikhan marked this pull request as ready for review July 26, 2026 03:52
Copilot AI review requested due to automatic review settings July 26, 2026 03:52

Copilot AI 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.

Pull request overview

Disables Chromium sandboxing for Playwright CLI workflows through the main job environment.

Changes:

  • Sets PLAYWRIGHT_MCP_SANDBOX=false for CLI mode.
  • Adds unit coverage and updates WASM golden outputs.
  • Clarifies an existing test assertion message.
Show a summary per file
File Description
pkg/workflow/compiler_main_job_helpers.go Adds the sandbox environment variable.
pkg/workflow/compiler_main_job_helpers_test.go Tests CLI-mode environment generation.
pkg/workflow/playwright_cli_test.go Clarifies assertion wording.
pkg/workflow/testdata/wasm_golden/WasmBinary/playwright-cli-mode.golden Updates generated WASM output.
pkg/workflow/testdata/TestWasmGolden_CompileFixtures/playwright-cli-mode.golden Updates compiled fixture output.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 2
  • Review effort level: Medium

Comment on lines 258 to 265
if isPlaywrightCLIMode(data.Tools) {
env = make(map[string]string)
env["PLAYWRIGHT_MCP_SANDBOX"] = "false"
}

if data.SafeOutputs != nil {
compilerMainJobLog.Printf("Configuring safe-outputs job env for main job (uploadAssets=%v)", data.SafeOutputs.UploadAssets != nil)
env = make(map[string]string)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 0074767. buildMainJobEnv now only initializes env when nil, so the safe-outputs branch no longer overwrites PLAYWRIGHT_MCP_SANDBOX. I also added a regression test covering playwright CLI + safe-outputs together.

})

require.Len(t, steps, 2, "expected npm install step plus skills install step")
require.Len(t, steps, 2, "expected npm install step and skills install step")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 0074767. The implementation intentionally uses job-level env (not an install step), and the stale mismatch concern is resolved by keeping tests aligned with that approach plus adding combined-mode regression coverage.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #48102 does not have the 'implementation' label and has only 28 new lines in business logic directories (threshold: 100).

@github-actions github-actions 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.

Review Summary

The fix correctly sets PLAYWRIGHT_MCP_SANDBOX=false for CLI mode, but there is a blocking bug: when SafeOutputs is also configured, line 265 reinitialises the env map unconditionally (env = make(map[string]string)), silently dropping PLAYWRIGHT_MCP_SANDBOX. Playwright-CLI workflows that also use safe-outputs will still fail at runtime.

The fix for line 265 is straightforward: use if env == nil { env = make(map[string]string) } before adding safe-output keys, rather than unconditionally reinitialising the map.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 16.9 AIC · ⌖ 4.53 AIC · ⊞ 5K

@github-actions github-actions 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.

Skills-Based Review

Applied /diagnosing-bugs — requesting changes on two correctness issues found in the diff.

📋 Key Themes & Highlights

Issues

  • Env map override bug: When Playwright CLI mode is combined with safe-outputs, the later safe-outputs branch in buildMainJobEnv re-initialises the map, silently dropping PLAYWRIGHT_MCP_SANDBOX. Merging keys instead of overwriting would fix this.
  • Stale test assertion: playwright_cli_test.go line 23 still expects 2 steps; the message text also no longer matches the implementation.

Positive Highlights

  • ✅ Root cause is correctly identified and addressed at the right layer.
  • ✅ New unit test in compiler_main_job_helpers_test.go covers the happy path cleanly.
  • ✅ Golden files updated consistently.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 14.6 AIC · ⌖ 4.56 AIC · ⊞ 6.7K
Comment /matt to run again

@github-actions github-actions 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.

REQUEST_CHANGES — One critical bug will cause PLAYWRIGHT_MCP_SANDBOX to be silently dropped in a common configuration.

🔍 Blocking issues

Critical: env map re-initialization drops Playwright env var

In buildMainJobEnv, the Playwright CLI block initializes env and sets PLAYWRIGHT_MCP_SANDBOX. The immediately following SafeOutputs block does env = make(map[string]string) unconditionally, wiping that entry. Any workflow using both playwright CLI mode and safe-outputs silently loses the sandbox disable.

Fix: use if env == nil { env = make(map[string]string) } consistently across all conditional branches in this function.

Medium: PR description and test assertions are out of sync

The PR description mentions a new Configure Playwright CLI sandbox install step (expecting 3 steps), but the implementation uses a job-level env var instead. The test still asserts 2 steps. Either the description is stale or the implementation is incomplete.

🔎 Code quality review by PR Code Quality Reviewer · sonnet46 · 18.8 AIC · ⌖ 4.56 AIC · ⊞ 5.7K
Comment /review to run again

@github-actions github-actions Bot mentioned this pull request Jul 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 88/100 — Excellent

Analyzed 1 behavioral test (1 new subtest added, 1 assertion message edit). 1 design, 0 implementation, 0 violations.

📊 Metrics (1 test)
Metric Value
Analyzed 1 (Go: 1, JS: 0)
✅ Design 1 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 1 (100%)
Duplicate clusters 0
Inflation No
🚨 Violations 0
Test File Classification Issues
TestBuildMainJobEnv/playwright CLI mode sets PLAYWRIGHT_MCP_SANDBOX=false compiler_main_job_helpers_test.go:260 design_test, behavioral_contract, high_value None
(message edit) TestGeneratePlaywrightCLIInstallSteps_DefaultVersionUsesCooldown playwright_cli_test.go:20 n/a (message-only edit) None

Verdict

passed. 0% implementation tests (threshold: 30%). The new subtest directly verifies the behavioral contract that PLAYWRIGHT_MCP_SANDBOX=false is injected into job env when playwright mode is cli — exactly aligned with the PR fix.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 35.7 AIC · ⌖ 11.1 AIC · ⊞ 8.1K ·
Comment /review to run again

@github-actions github-actions 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.

✅ Test Quality Sentinel: 88/100. 0% implementation tests (threshold: 30%).

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, address the unresolved review feedback and failed checks below, and rerun checks once the branch is up to date.

Unresolved review feedback:...

Implemented in 0074767.

  • Fixed unresolved review feedback by preserving PLAYWRIGHT_MCP_SANDBOX when safe-outputs is enabled, and added a combined-mode regression test.
  • Investigated both failed test jobs; both fail on TestFallbackAWFilesMatchesLocalAWDirectory in pkg/cli, which is outside this PR’s changed area.
  • Ran local validation for this change (make fmt, make lint, targeted go test ./pkg/workflow, make test-unit) and also ran parallel validation (no review findings; no CodeQL alerts).

I can’t re-trigger CI from this agent environment; a maintainer needs to re-run checks.

Copilot AI requested a review from gh-aw-bot July 26, 2026 07:55
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, verify the replied review threads are ready to resolve, and document any remaining blockers before rerunning checks if needed.

Replied review threads:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14 AIC · ⌖ 8.18 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, verify the replied review threads are ready to resolve, and document any remaining blockers before rerunning checks if needed.

Replied review threads:...

Verified.

Remaining blockers:

  • I don’t have a thread-resolution write path in this agent context, so I cannot mark those threads resolved directly.
  • I also cannot re-trigger workflow runs from this agent environment.

CI context (from requested failed jobs): both failures are the same pkg/cli test (TestFallbackAWFilesMatchesLocalAWDirectory) reporting fallback JSON drift vs .github/aw/*.md, which is outside this PR’s Playwright env fix scope.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage

Field Value
Category bug
Risk 🟢 Low
Priority Score 56/100
Score Breakdown Impact: 25, Urgency: 18, Quality: 13
Action fast_track — CI mostly passing (17✅ 1❌ 5⏳), targeted fix

Playwright CLI mode sandbox fix. 1 CI failure present — needs investigation before merge.

Generated by 🔧 PR Triage Agent · sonnet46 · 26.8 AIC · ⌖ 4.99 AIC · ⊞ 5.7K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, verify whether the Playwright sandbox fix is now fully ready for maintainer review, address any still-open review feedback, and follow up on the failed check below if it is still relevant.

Failed checks:

Recent context:

  • You previously said the replied review threads were ready to resolve and that the observed CI failure was outside this PR scope.
  • Please summarize the current blocker status for maintainers in one concise update.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 23.1 AIC · ⌖ 6.65 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, verify whether the Playwright sandbox fix is now fully ready for maintainer review, address any still-open review feedback, and follow up on the failed che...

Current status: the Playwright sandbox fix is ready for maintainer review from a code perspective.

  • Still-open Copilot threads: both are already addressed in code/replies (00747671e0), with one now outdated; no further code changes needed, but I can’t resolve threads from this agent context.
  • Failed check (Alpine Container Test, run 30195020104, job 89793859141) is still relevant only as a stale CI signal on this head: it failed in Build Alpine Docker image due to Docker Hub pull timeout (alpine:3.21 manifest fetch i/o timeout), i.e., infra/network, not the Playwright change.

Maintainer blocker summary: resolve the two replied review threads and re-trigger CI (close/reopen, workflow_dispatch, or maintainer push) to refresh checks on current HEAD before merge.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, make sure the replied review feedback below is fully resolved in GitHub, and re-check the failed CI signal before handing back to maintainers.

Replied review feedback still showing unresolved:

Failed checks:

Please summarize whether any code changes are still needed or whether this only needs thread resolution and fresh CI on the current head.

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.5 AIC · ⌖ 7.28 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

@copilot please run the pr-finisher skill, make sure the replied review feedback below is fully resolved in GitHub, and re-check the failed CI signal before handing back to maintainers.

Replied rev...

No further code changes are needed for this PR’s Playwright fix.

Current blocker status:

  • r3651695238 (safe-outputs preserving PLAYWRIGHT_MCP_SANDBOX) is already fixed in code (00747671e0) and the thread is outdated.
  • r3651695239 is still open in GitHub because the PR description text still describes the old step-based approach; implementation is job-level env. This is a metadata/thread-resolution item, not a code defect.
  • Failed CI signal (Alpine Container Test, run 30195020104, job 89793859141) still points to Docker Hub network timeout while pulling alpine:3.21 (registry-1.docker.io ... i/o timeout), not a Playwright regression.

Hand-off: this now needs thread resolution + PR description alignment in GitHub and a fresh CI re-run on current head.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, make sure the replied review feedback below is fully resolved in GitHub, and re-check the failed CI signal before handing this back to maintainers.

Recent author follow-up:

Unresolved review feedback still showing on this PR (newest first):

Failed checks:

Please state clearly whether any code changes are still needed, or whether this only needs thread resolution / PR metadata cleanup and fresh CI on the current head.

Generated by 👨🍳 PR Sous Chef
Comment /souschef to run again

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 28.5 AIC · ⌖ 13 AIC · ⊞ 7.1K ·
Comment /souschef to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, make sure the author's latest follow-up fully resolves the still-open review feedback below in GitHub terms, and re-check whether the failed CI signal still matters on the current head before handing this back to maintainers.

Recent author follow-up:

Unresolved review feedback still showing on this PR (newest first):

Failed checks:

Please state clearly whether any code changes are still needed, or whether this only needs thread resolution / PR metadata cleanup and fresh CI on the current head.

Generated by 👨🍳 PR Sous Chef
Comment /souschef to run again

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 23.3 AIC · ⌖ 7.77 AIC · ⊞ 7.1K ·
Comment /souschef to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, verify the author follow-up against the still-unresolved review feedback below, re-check the failed CI signal on the current head, and summarize whether this PR is ready for maintainer review.

Recent author follow-up:

Unresolved review feedback still showing on this PR (newest first):

Failed checks:

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 17.2 AIC · ⌖ 7.8 AIC · ⊞ 7.1K ·
Comment /souschef to run again

@github-actions

Copy link
Copy Markdown
Contributor

🤖 PR Triage — §30214847023

Field Value
Category bug
Risk 🟢 Low
Priority 60/100
Breakdown Impact 22 · Urgency 20 · Quality 18
Action fast_track

Rationale: Chromium sandbox disable for playwright-cli in CI containers. Low-risk: 65 additions in 19 files (mostly lock.yml recompiles). CI passing. AI reviewer approved. Ready for expedited human review.

Generated by 🔧 PR Triage Agent · sonnet46 · 34.1 AIC · ⌖ 7.94 AIC · ⊞ 5.7K ·

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the skill, review the current branch state, address any still-open reviewer feedback and failed checks, and reply with whether this PR is ready for maintainer review.

Run: https://github.com/github/gh-aw/actions/runs/30215321924

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 16.9 AIC · ⌖ 7.13 AIC · ⊞ 5.6K ·
Comment /souschef to run again

@pelikhan
pelikhan merged commit d4872c2 into main Jul 26, 2026
28 of 29 checks passed
@pelikhan
pelikhan deleted the copilot/fix-chrome-sandbox-issue branch July 26, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants