Suggest tools.github.mode: gh-proxy when api.github.com is firewall-blocked#28293
Suggest tools.github.mode: gh-proxy when api.github.com is firewall-blocked#28293
tools.github.mode: gh-proxy when api.github.com is firewall-blocked#28293Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/6e7ed1c2-999b-4c24-8057-c2f9d020badc Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| const hasGitHubApiBlocked = blockedDomains.includes("api.github.com"); | ||
|
|
||
| if (hasGitHubApiBlocked) { | ||
| section += `> **💡 Tip:** \`api.github.com\` is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding \`api.github.com\` to \`network.allowed\`, use \`tools.github.mode: gh-proxy\` for direct pre-authenticated GitHub CLI access without requiring network access to \`api.github.com\`:\n`; |
There was a problem hiding this comment.
@copilot move text into markdown template in actions/setup/md and use render template function helper
There was a problem hiding this comment.
Done in 2eb2067. Created actions/setup/md/firewall_blocked_domains.md with {key} placeholders for all dynamic content, and updated generateBlockedDomainsSection to use renderTemplateFromFile from messages_core.cjs. Tests pass the source-tree template path explicitly via an optional second parameter.
…erTemplateFromFile Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c419322e-1c45-4004-bc12-fa668a0f1736 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/c419322e-1c45-4004-bc12-fa668a0f1736 Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| // Build optional gh-proxy tip if api.github.com is blocked | ||
| const hasGitHubApiBlocked = blockedDomains.includes("api.github.com"); | ||
| const ghProxyTip = hasGitHubApiBlocked | ||
| ? `> **💡 Tip:** \`api.github.com\` is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding \`api.github.com\` to \`network.allowed\`, use \`tools.github.mode: gh-proxy\` for direct pre-authenticated GitHub CLI access without requiring network access to \`api.github.com\`:\n` + |
There was a problem hiding this comment.
@copilot move this tip to template file as well
There was a problem hiding this comment.
Done in 4e3a6c9. The tip text now lives in firewall_blocked_domains.md inside a {{#if {has_github_api_blocked}}}...{{/if}} block. The JS passes has_github_api_blocked: "true"/"false" to renderTemplateFromFile, then chains renderMarkdownTemplate for the conditional pass (isTruthy("false") === false per the template engine's explicit check).
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/211e7bfd-9bea-49c0-bc8e-66c11a68d91a Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/211e7bfd-9bea-49c0-bc8e-66c11a68d91a Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
🧪 Test Quality Sentinel ReportTest Quality Score: 100/100✅ Excellent test quality
Test Classification Details
Flagged Tests — Requires ReviewNone. All new tests are high-quality behavioral tests. Language SupportTests analyzed:
Verdict
All five new tests assert on observable return values and cover important behavioral contracts: iptables-dropped traffic fallback, Squid internal error filtering, 📖 Understanding Test ClassificationsDesign Tests (High Value) verify what the system does:
Implementation Tests (Low Value) verify how the system does it:
Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators. References: §24898168106
|
There was a problem hiding this comment.
Pull request overview
Updates the firewall-blocked-domains warning to give targeted guidance when api.github.com is blocked, steering users toward GitHub Tools gh-proxy mode instead of adding the GitHub API domain to network.allowed.
Changes:
- Adds a conditional “gh-proxy” tip when
api.github.comappears in the blocked domain list. - Refactors
generateBlockedDomainsSectionto render from a Markdown template with placeholder substitution + conditional processing. - Extends test coverage with cases for
api.github.compresent/absent.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/md/firewall_blocked_domains.md | Adds templated warning content and conditional gh-proxy tip when GitHub API is blocked. |
| actions/setup/js/firewall_blocked_domains.cjs | Switches blocked-domain section generation to template rendering and adds api.github.com detection. |
| actions/setup/js/firewall_blocked_domains.test.cjs | Adds/updates tests to validate the new tip behavior and template-based rendering. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 4
| > | ||
| > The following {domain_word} {verb} blocked by the firewall during workflow execution: | ||
| > | ||
| {domain_list}> |
There was a problem hiding this comment.
The {domain_list} placeholder line ends with an extra > ({domain_list}>), which will render an unintended standalone blockquote marker after the bullet list. Remove the trailing > so the rendered warning block doesn’t include a spurious > line.
| {domain_list}> | |
| {domain_list} |
| > network: | ||
| > allowed: | ||
| > - defaults | ||
| {yaml_network_list}> ``` |
There was a problem hiding this comment.
The YAML list placeholder and the closing code fence are currently on the same template line ({yaml_network_list}> ````). This is fragile and can produce malformed Markdown depending on whether the placeholder expansion ends with a newline. Put {yaml_network_list}on its own line and keep the closing> ``` on the next line (and remove any stray>` after the placeholder) so the fenced block is always well-formed.
| {yaml_network_list}> ``` | |
| {yaml_network_list} | |
| > ``` |
| * Generates HTML details/summary section for blocked domains wrapped in a GitHub warning alert | ||
| * @param {string[]} blockedDomains - Array of blocked domain names | ||
| * @param {string[]} blockedDomains - Array of blocked domain names (expected to be pre-sanitized via getBlockedDomains) | ||
| * @param {string} [templatePath] - Optional path to template file (defaults to RUNNER_TEMP/gh-aw/prompts/firewall_blocked_domains.md) |
There was a problem hiding this comment.
The JSDoc still says this function generates an “HTML details/summary section”, but the implementation now renders a Markdown warning alert from a template. Update the description to match the actual output to avoid confusing future maintainers.
See below for a potential fix:
* Renders a Markdown GitHub warning alert for blocked domains from a template
* @param {string[]} blockedDomains - Array of blocked domain names (expected to be pre-sanitized via getBlockedDomains)
* @param {string} [templatePath] - Optional path to template file (defaults to RUNNER_TEMP/gh-aw/prompts/firewall_blocked_domains.md)
* @returns {string} Rendered Markdown warning alert, or empty string if no blocked domains
| // Resolve template path: explicit > RUNNER_TEMP (production) > source tree (local dev/test) | ||
| let resolvedTemplatePath = templatePath; | ||
| if (!resolvedTemplatePath) { | ||
| resolvedTemplatePath = process.env.RUNNER_TEMP ? `${process.env.RUNNER_TEMP}/gh-aw/prompts/firewall_blocked_domains.md` : path.join(__dirname, "../md/firewall_blocked_domains.md"); |
There was a problem hiding this comment.
Template path resolution here doesn’t honor the existing GH_AW_PROMPTS_DIR override that other prompt-rendering code uses (e.g., actions/setup/js/comment_memory.cjs:24 and actions/setup/js/gateway_difc_filtered.cjs:128). To keep behavior consistent (and make testing/overrides work uniformly), consider resolving promptsDir via process.env.GH_AW_PROMPTS_DIR || ${process.env.RUNNER_TEMP}/gh-aw/prompts`` when templatePath isn’t provided.
| // Resolve template path: explicit > RUNNER_TEMP (production) > source tree (local dev/test) | |
| let resolvedTemplatePath = templatePath; | |
| if (!resolvedTemplatePath) { | |
| resolvedTemplatePath = process.env.RUNNER_TEMP ? `${process.env.RUNNER_TEMP}/gh-aw/prompts/firewall_blocked_domains.md` : path.join(__dirname, "../md/firewall_blocked_domains.md"); | |
| // Resolve template path: explicit > GH_AW_PROMPTS_DIR override > RUNNER_TEMP (production) > source tree (local dev/test) | |
| let resolvedTemplatePath = templatePath; | |
| if (!resolvedTemplatePath) { | |
| const promptsDir = | |
| process.env.GH_AW_PROMPTS_DIR || | |
| (process.env.RUNNER_TEMP && `${process.env.RUNNER_TEMP}/gh-aw/prompts`); | |
| resolvedTemplatePath = promptsDir | |
| ? path.join(promptsDir, "firewall_blocked_domains.md") | |
| : path.join(__dirname, "../md/firewall_blocked_domains.md"); |
When the sandbox firewall blocks
api.github.com, the alert in the agent issue/comment body should steer users towardtools.github.mode: gh-proxyrather than blindly addingapi.github.comtonetwork.allowed.Changes
firewall_blocked_domains.cjs—generateBlockedDomainsSectionnow detectsapi.github.comin the blocked list and injects a tip before thenetwork.allowedsnippet:Includes a YAML example and a link to the GitHub Tools docs.
firewall_blocked_domains.test.cjs— Three new cases:api.github.comalone, mixed with other blocked domains, and absent (no tip shown).