Skip to content

[q] Simplify Playwright configuration - localhost domains now included by default #6434

@github-actions

Description

@github-actions

Summary

This PR removes explicit allowed_domains configuration for Playwright in workflows that only specify localhost and 127.0.0.1, since these domains are now automatically included by default when using Playwright.

Context from Issue #5733

Issue #5733 identified that the daily-multi-device-docs-tester workflow was encountering connection issues with localhost during Playwright browser testing in GitHub Actions. The user @pelikhan requested: "/q the playwright default domain set should allow localhost 127.0.0.1"

Key Finding: The system already includes localhost by default! The codebase has:

  • constants.DefaultAllowedDomains = ["localhost", "localhost:*", "127.0.0.1", "127.0.0.1:*"]
  • EnsureLocalhostDomains() function that guarantees localhost is always present
  • Automatic application when no allowed_domains is specified

Changes Made

Workflows Updated

  1. .github/workflows/daily-multi-device-docs-tester.md

    • ❌ Removed: Explicit allowed_domains: ["localhost", "127.0.0.1"]
    • ✅ Result: Uses default localhost domains automatically
  2. .github/workflows/docs-noob-tester.md

    • ❌ Removed: Explicit allowed_domains: ["localhost", "127.0.0.1"]
    • ✅ Result: Uses default localhost domains automatically

Verification

Both compiled workflows now have the correct default configuration:

"args": [
  "run", "-i", "--rm", "--init", 
  "mcr.microsoft.com/playwright/mcp",
  "--output-dir", "/tmp/gh-aw/mcp-logs/playwright",
  "--allowed-hosts", "localhost;localhost:*;127.0.0.1;127.0.0.1:*"
]

How It Works

The system automatically ensures localhost domains are available:

  1. When no allowed_domains is specified: Uses constants.DefaultAllowedDomains
  2. When custom domains are specified: Calls EnsureLocalhostDomains() to merge them with localhost
  3. Result: Localhost is ALWAYS available, whether you specify it or not

Benefits

Cleaner workflow definitions - No need to explicitly list localhost
Consistent behavior - All workflows get localhost by default
Less maintenance - One less thing to remember when creating new workflows
Security preserved - Custom domains still require explicit configuration

Note About Issue #5733

The original issue reported that Playwright couldn't connect to localhost in GitHub Actions due to browser sandbox restrictions - this is a GitHub Actions environment limitation, not a configuration issue. The sandbox blocks localhost connections regardless of our allowed_domains setting.

However, this PR still improves the configuration by:

  • Making the default behavior explicit
  • Removing redundant configuration
  • Ensuring consistency across all workflows

Testing

  • ✅ Compiled both workflows successfully with gh-aw compile
  • ✅ Verified lock files contain correct --allowed-hosts configuration
  • ✅ No compilation errors or warnings
  • ✅ 4 files changed: 2 insertions(+), 14 deletions(-)

Related

  • Fixes #5733 (by clarifying default behavior)
  • Related code: pkg/parser/mcp.go:EnsureLocalhostDomains()
  • Related code: pkg/constants/constants.go:DefaultAllowedDomains

AI generated by Q


Note

This was originally intended as a pull request, but the git push operation failed.

Workflow Run: View run details and download patch artifact

The patch file is available as an artifact (aw.patch) in the workflow run linked above.
To apply the patch locally:

# Download the artifact from the workflow run https://github.com/githubnext/gh-aw/actions/runs/20210202102
# (Use GitHub MCP tools if gh CLI is not available)
gh run download 20210202102 -n aw.patch
# Apply the patch
git am aw.patch
Show patch preview (97 of 97 lines)
From 7c490631b8e0d3d95022f173d2be9f8227302fa3 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sun, 14 Dec 2025 15:39:30 +0000
Subject: [PATCH] Simplify Playwright config - use default localhost domains

- Remove explicit allowed_domains for localhost/127.0.0.1 in workflows
- These domains are automatically included by constants.DefaultAllowedDomains
- EnsureLocalhostDomains() guarantees localhost is always present
- Updated workflows: daily-multi-device-docs-tester, docs-noob-tester
- Verified compiled lock files contain correct --allowed-hosts configuration

Fixes #5733
---
 .github/workflows/daily-multi-device-docs-tester.lock.yml | 5 +----
 .github/workflows/daily-multi-device-docs-tester.md       | 3 ---
 .github/workflows/docs-noob-tester.lock.yml               | 5 +----
 .github/workflows/docs-noob-tester.md                     | 3 ---
 4 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/daily-multi-device-docs-tester.lock.yml b/.github/workflows/daily-multi-device-docs-tester.lock.yml
index c899d23..742a966 100644
--- a/.github/workflows/daily-multi-device-docs-tester.lock.yml
+++ b/.github/workflows/daily-multi-device-docs-tester.lock.yml
@@ -48,9 +48,6 @@
 # tools:
 #   playwright:
 #     version: "v1.56.1"
-#     allowed_domains:
-#       - "localhost"
-#       - "127.0.0.1"
 #   bash:
 #     - "npm install*"
 #     - "npm run build*"
@@ -2138,7 +2135,7 @@ jobs:
                   "--output-dir",
                   "/tmp/gh-aw/mcp-logs/playwright",
                   "--allowed-hosts",
-                  "localhost:*;127.0.0.1:*;localhost;127.0.0.1"
+                  "localhost;localhost:*;127.0.0.1;127.0.0.1:*"
                 ]
               },
               "safeoutputs": {
diff --git a/.github/workflows/daily-multi-device-docs-tester.md b/.github/workflows/daily-multi-device-docs-tester.md
index 4c0d41c..10e96e6 100644
--- a/.github/workflows/daily-multi-device-
... (truncated)

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions