Skip to content

fix: run cli correctly in compiled bun hosts - #301

Merged
pchuri merged 4 commits into
pchuri:mainfrom
erikh3:fix/compiled-bun-cli-runtime
Nov 30, 2026
Merged

pchuri merged 4 commits into
pchuri:mainfrom
erikh3:fix/compiled-bun-cli-runtime

Conversation

@erikh3

@erikh3 erikh3 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Run CLI subprocesses correctly from compiled Bun hosts with BUN_BE_BUN=1. Pass --no-env-file to Bun children so untrusted project .env files cannot bypass the filtered environment. Node behavior remains unchanged.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Testing

  • Plain and compiled Bun regressions reject project .env and .env.local injection while preserving trusted settings.
  • Linux container: Node 24.22.2, npm 11.19.1, Bun 1.3.14; lint and all 2017 tests passed.
  • Workflow YAML validated; pinned Bun setup runs only in Node 24.x.

Checklist

  • Removed the unclear README sentence.
  • Runtime protections preserved.

Local verification exercised job commands, not the GitHub Actions runner itself.

@erikh3
erikh3 marked this pull request as ready for review November 15, 2026 09:41
@pchuri

pchuri commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix! Setting BUN_BE_BUN after buildCliEnvironment() filters the env looks right, and since the child is spawned via process.execPath, this is exactly what a compiled host needs.

One concern before merging:

Bun auto-loads .env from the child's cwd. The CLI subprocess runs with cwd = projectRoot (the user's project), and Bun loads .env / .env.local from the current directory by default. The CLI reads several settings straight from process.env (e.g. CONFLUENCE_DOMAIN in lib/config.js, CONFLUENCE_ALLOW_INSECURE_HTTP in lib/confluence-client.js), so a .env in an untrusted project could re-introduce values the allowlist is meant to keep out — for example pointing CONFLUENCE_DOMAIN at another host, which would send the stored token there. Plain Bun hosts already had this exposure; this PR extends it to compiled hosts, which previously just failed.

I haven't reproduced this myself (no Bun on my machine), so please correct me if Bun skips .env loading in this mode. If it does load it, could you disable env-file loading for the child when process.versions.bun is set (e.g. --no-env-file, if the Bun versions we support have it) and add a test with a .env in projectRoot?

Minor:

  • CI has no Bun setup step, so the new tests will always be skipped there. Adding oven-sh/setup-bun to one matrix job would let them actually run.
  • The README sentence ("Compiled Bun hosts run CLI subprocesses automatically…") is a bit hard to act on. Maybe name the symptom it fixes, or drop it.

I'll approve the CI run so the existing suite runs on this branch.

@erikh3

erikh3 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for catching the env-file issue. Confirmed that Bun auto-loads project .env files.

Updated the runner to pass --no-env-file to Bun children. Plain and compiled Bun regressions place both .env and .env.local in projectRoot and verify that injected settings stay out while trusted settings, arguments, and cwd are preserved. Node behavior remains unchanged.

Added SHA-pinned oven-sh/setup-bun v2.2.0 to the Node 24 matrix job, using Bun 1.3.14. Removed the README sentence.

@pchuri pchuri left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks a lot for this fix, @erikh3! Really appreciate the careful work — especially closing the .env injection path for Bun children, which I hadn't considered.

Review notes:

  • The change is minimal and well-scoped: BUN_BE_BUN=1 and --no-env-file apply only when the host runs on Bun, so Node behavior is untouched.
  • The regression test covers both plain and compiled Bun hosts and asserts that untrusted .env / .env.local values never reach the child. Nice.
  • Pinning oven-sh/setup-bun by commit SHA and limiting it to the 24.x matrix keeps CI lean.

No blocking issues from my side. I'll approve the pending CI run and merge once it's green.

@pchuri
pchuri merged commit a56d78d into pchuri:main Nov 30, 2026
6 checks passed
github-actions Bot pushed a commit that referenced this pull request Nov 30, 2026
## [2.31.4](v2.31.3...v2.31.4) (2026-11-30)

### Bug Fixes

* run cli correctly in compiled bun hosts ([#301](#301)) ([a56d78d](a56d78d))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.31.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants