Skip to content

fix: make ~/.gemini setup conditional on geminiApiKey#2282

Merged
lpcox merged 3 commits intomainfrom
copilot/fix-gemini-issue-in-copilot
Apr 29, 2026
Merged

fix: make ~/.gemini setup conditional on geminiApiKey#2282
lpcox merged 3 commits intomainfrom
copilot/fix-gemini-issue-in-copilot

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

Gemini CLI artifacts (~/.gemini mount, GEMINI_API_KEY placeholder, GEMINI_API_BASE_URL, ownership fix in entrypoint) were unconditionally applied to every AWF run, producing suspicious log entries like [entrypoint] Ensured ~/.gemini ownership for chroot user in Copilot-only runs that have no relationship to Gemini.

Changes

  • generateDockerCompose()~/.gemini bind mount, GEMINI_API_BASE_URL, and GEMINI_API_KEY placeholder are now gated on config.geminiApiKey. New AWF_GEMINI_ENABLED=1 env var signals Gemini is active.
  • writeConfigs()~/.gemini host directory pre-creation is conditional on config.geminiApiKey.
  • entrypoint.sh~/.gemini ownership fix is now wrapped in [ -n "${AWF_GEMINI_ENABLED}" ], eliminating the log noise in non-Gemini runs.
  • Tests — Updated to assert GEMINI_API_BASE_URL, GEMINI_API_KEY, and ~/.gemini mount are absent without a Gemini key; added coverage for the AWF_GEMINI_ENABLED signal and conditional ~/.gemini pre-creation.

Copilot AI linked an issue Apr 28, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix Gemini issue when using Copilot fix: make ~/.gemini setup conditional on geminiApiKey Apr 28, 2026
Copilot AI requested a review from lpcox April 28, 2026 21:07
@lpcox lpcox marked this pull request as ready for review April 28, 2026 23:06
@lpcox lpcox requested a review from Mossaka as a code owner April 28, 2026 23:06
Copilot AI review requested due to automatic review settings April 28, 2026 23:06
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 86.08% 86.16% 📈 +0.08%
Statements 86.08% 86.15% 📈 +0.07%
Functions 88.18% 88.18% ➡️ +0.00%
Branches 80.27% 80.36% 📈 +0.09%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/docker-manager.ts 87.4% → 87.7% (+0.29%) 87.0% → 87.3% (+0.27%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

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

This PR makes Gemini-specific runtime behavior in AWF conditional on geminiApiKey, so non-Gemini runs (e.g., Copilot-only) don’t mount ~/.gemini, set Gemini proxy env vars, or emit Gemini-related entrypoint logs.

Changes:

  • Gate ~/.gemini bind mount, GEMINI_API_BASE_URL, GEMINI_API_KEY placeholder, and new AWF_GEMINI_ENABLED signal on config.geminiApiKey.
  • Make writeConfigs() only pre-create ~/.gemini when Gemini is enabled.
  • Wrap the entrypoint’s ~/.gemini ownership fix behind AWF_GEMINI_ENABLED, and update tests accordingly.
Show a summary per file
File Description
src/docker-manager.ts Adds AWF_GEMINI_ENABLED and gates Gemini mounts/env configuration on geminiApiKey.
src/docker-manager.test.ts Updates/extends tests to assert Gemini artifacts are absent without a Gemini key and present when configured.
containers/agent/entrypoint.sh Runs ~/.gemini ownership fix only when AWF_GEMINI_ENABLED is set to avoid non-Gemini log noise.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (1)

src/docker-manager.test.ts:3781

  • Same restoration issue here: assigning process.env.HOME = originalHome when originalHome is undefined sets HOME to the literal string "undefined". Restore by conditionally setting vs deleting HOME (and SUDO_USER) to avoid cross-test contamination.
      process.env.HOME = originalHome;
      if (originalSudoUser) {
        process.env.SUDO_USER = originalSudoUser;
      }
  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread src/docker-manager.ts

// Signal to entrypoint.sh that Gemini CLI is expected — only when geminiApiKey is configured.
// This guards the ~/.gemini ownership fix and avoids spurious Gemini-related log output in
// Copilot (or other non-Gemini) runs.
Comment thread src/docker-manager.test.ts Outdated
Comment on lines +3747 to +3750
process.env.HOME = originalHome;
if (originalSudoUser) {
process.env.SUDO_USER = originalSudoUser;
}
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@lpcox
Copy link
Copy Markdown
Collaborator

lpcox commented Apr 28, 2026

@copilot address the review feedback

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 28, 2026

@copilot address the review feedback

Addressed both review items in f3e57ba:

  1. Added AWF_GEMINI_ENABLED to EXCLUDED_ENV_VARS (alongside AWF_PREFLIGHT_BINARY) so a host-provided value can never be inherited via --env-all. Added a test to verify this.
  2. Fixed both process.env.HOME restoration sites to use if (originalHome !== undefined) ... else delete process.env.HOME (and same for SUDO_USER).

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results
✅ GitHub MCP: #2276, #2271
✅ Playwright: GitHub page title verified
✅ File writing: Test file created
✅ Bash: File verified

Status: PASS

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Smoke Test Results

Test Status
GitHub MCP connectivity ✅ PR listed successfully
GitHub.com HTTP ✅ 200/301
File write/read /tmp/gh-aw/agent/smoke-test-copilot-25083440493.txt verified

PR: fix: make ~/.gemini setup conditional on geminiApiKey
Author: @Copilot | Assignees: @lpcox, @Copilot

Overall: ✅ PASS

📰 BREAKING: Report filed by Smoke Copilot

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Version Comparison Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.14.1 v20.20.2
Go go1.22.12 go1.22.12

Overall: ❌ Not all versions match — Python and Node.js differ between host and chroot environments.

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

fix: block Shocker container-escape syscalls in seccomp profile (CVE-2014-9357)
chore: upgrade to firewall v0.25.29 and mcpg v0.3.1
fix: make ~/.gemini setup conditional on geminiApiKey
perf(security-guard): eliminate redundant API call and raise diff pre-fetch limit to 100 KB
GitHub MCP ❌ | safeinputs-gh ❌ | Playwright ✅ | Tavily ❌
File write ✅ | Bash cat ✅ | Discussion comment ✅ | Build ✅
Overall: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx all passed ✅ PASS
Node.js execa all passed ✅ PASS
Node.js p-limit all passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Note (Java): Maven's local repository defaulted to a root-owned /home/runner/.m2/repository; tests were run with -Dmaven.repo.local=/tmp/gh-aw/agent/.m2/repository as a workaround, which succeeded.

Generated by Build Test Suite for issue #2282 · ● 421.4K ·

@lpcox lpcox merged commit cb8ca4b into main Apr 29, 2026
64 of 68 checks passed
@lpcox lpcox deleted the copilot/fix-gemini-issue-in-copilot branch April 29, 2026 00:14
@github-actions
Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot BYOK — PASS

Test Result
GitHub MCP (list PRs)
GitHub.com connectivity
File write/read (smoke-test-copilot-byok-25086053460.txt)
BYOK inference (agent → api-proxy → api.githubcopilot.com)

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com.

Overall: PASS@lpcox / assignees: @lpcox, @Copilot

🔑 BYOK report filed by Smoke Copilot BYOK

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.

Gemini when using copilot

3 participants