fix: add size-based filtering to --env-all to prevent E2BIG#1978
Conversation
Add MAX_ENV_VALUE_SIZE (64KB) per-variable cap to --env-all passthrough. Variables exceeding this threshold are skipped with a warning listing the dropped keys and their sizes. Also add a total environment size warning when the combined env approaches ARG_MAX (~1.5MB threshold). This prevents the 'Argument list too long' (E2BIG) kernel error that occurs when the runner environment (~1.5-2MB) is combined with large command arguments (e.g., inlined prompts). Closes #1965 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
There was a problem hiding this comment.
Pull request overview
Adds guardrails around --env-all passthrough to reduce the likelihood of Linux E2BIG (ARG_MAX) failures when large GitHub Actions runner environments are combined with large command arguments.
Changes:
- Skip individual
process.envvariables whose values exceed a fixed per-variable size threshold during--env-allpassthrough, emitting warnings listing what was skipped. - Emit a warning when the constructed container environment (after
--env-all,--env-file, and--env) exceeds a total-size warning threshold. - Add unit tests covering “oversized var skipped” and “normal var included” behaviors.
Show a summary per file
| File | Description |
|---|---|
src/docker-manager.ts |
Adds per-variable filtering and overall env-size warning to reduce ARG_MAX/E2BIG risk when --env-all is used. |
src/docker-manager.test.ts |
Adds tests validating that oversized env vars are skipped and normal-sized ones still pass through under --env-all. |
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.ts:946
- The total environment size warning is described in bytes, but the calculation uses
k.length/v.length(UTF-16 code units). This can significantly undercount actual envp size and reduce the usefulness of the ARG_MAX warning. Consider switching toBuffer.byteLengthfor both key and value and keeping the+ 2only for the literal=and NUL terminator bytes.
const totalEnvBytes = Object.entries(environment)
.reduce((sum, [k, v]) => sum + k.length + (v?.length ?? 0) + 2, 0); // +2 for '=' and null
if (totalEnvBytes > ENV_SIZE_WARNING_THRESHOLD) {
logger.warn(
`⚠️ Total container environment size is ${(totalEnvBytes / 1024).toFixed(0)} KB — ` +
'may cause E2BIG (Argument list too long) errors when combined with large command arguments'
);
logger.warn(' Consider using --exclude-env to remove unnecessary variables');
}
- Files reviewed: 2/2 changed files
- Comments generated: 1
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Smoke Test Results✅ GitHub MCP: feat: add upstream corporate proxy support (#1976), optimize(secret-digger-claude): default threat detection to Haiku (#1974) Overall: PASS
|
🔥 Smoke Test Results
PR: fix: add size-based filtering to --env-all to prevent E2BIG Overall: PASS ✅
|
Chroot Version Comparison Results
Overall: ❌ Not all versions matched. Python and Node.js versions differ between the host and chroot environment. Go versions match. The chroot appears to be running older versions of Python (3.12.3 vs 3.12.13) and Node.js (v20.20.2 vs v24.14.1).
|
This comment has been minimized.
This comment has been minimized.
|
🔮 The ancient spirits stir at the firewall gate.
|
Smoke Test: GitHub Actions Services Connectivity ✅All checks passed:
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Summary
Adds size-based filtering to
--env-allpassthrough to preventE2BIG(Argument list too long) kernel errors when the runner environment is too large.Problem
On GitHub Actions runners,
--env-allforwards the full environment (~1.5–2 MB ofGITHUB_*, tool-cache, matrix vars, etc.) into the container. Combined with large command arguments (e.g., inlined prompts via--prompt \"$(cat ...)\"), this exceeds the LinuxARG_MAXlimit (~2 MB forargv + envp), causing:Changes
src/docker-manager.tsPer-variable size cap (
MAX_ENV_VALUE_SIZE = 64KB):--env-allpassthrough--env VAR=\"\$VAR\"Total environment size warning (
ENV_SIZE_WARNING_THRESHOLD = 1.5MB):--exclude-envTests (2 new)
Design Decisions
--env VARexplicitly--prompt-fileinstead of shell expansion) is tracked upstream in gh-awCloses #1965