Skip to content

cli: add BUN_CONFIG_ELIDE_LINES env var - #28978

Open
alii wants to merge 1 commit into
mainfrom
claude/bun-config-elide-lines-env
Open

alii wants to merge 1 commit into
mainfrom
claude/bun-config-elide-lines-env

Conversation

@alii

@alii alii commented Apr 8, 2026

Copy link
Copy Markdown
Member

Split out from #18111 by @martinamps.

Adds BUN_CONFIG_ELIDE_LINES as an environment-variable equivalent of --elide-lines, so the limit can be set once globally instead of per command. The CLI flag takes precedence when both are set.

Closes #11465

@robobun

robobun commented Apr 8, 2026 •

Copy link
Copy Markdown
Collaborator
Updated 4:26 AM PT - May 30th, 2026

❌ @robobun, your commit a3a7bb2 has 2 failures in Build #59204 (All Failures):


🧪   To try this PR locally:

bunx bun-pr 28978

That installs a local version of the PR into your bun-28978 executable, so you can run:

bun-28978 --bun

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Found 1 issue this PR may fix:

  1. Ellide-lines toml config #17918 - Requests a config option for elide-lines outside CLI flags; the new BUN_CONFIG_ELIDE_LINES env var provides exactly that global configuration mechanism

If this is helpful, consider adding Fixes #17918 to the PR description to auto-close the issue on merge.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Apr 8, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Added support for configuring the maximum number of lines of script output shown when using bun run --filter. Users can now set this via the BUN_CONFIG_ELIDE_LINES environment variable, --elide-lines CLI argument, or run.elide-lines in bunfig.toml, with proper precedence handling and validation.

Changes

Cohort / File(s) Summary
Environment Variable & CLI Argument Handling
src/env_var.zig, src/cli/Arguments.zig
Added new BUN_CONFIG_ELIDE_LINES environment variable definition. Refactored --elide-lines parsing into a parseElideLinesOption() helper that resolves values from CLI arguments with fallback to the environment variable, with proper error handling for invalid integers.
Configuration Validation
src/bunfig.zig
Added validation for run.elide-lines in bunfig.toml to reject negative, non-finite, fractional, or oversized values with appropriate error messaging at parse time.
Tests
test/cli/run/filter-workspace.test.ts
Refactored runElideLinesTest helper to support optional environment variable overrides and conditional CLI arguments. Added test cases validating BUN_CONFIG_ELIDE_LINES behavior, CLI precedence over environment variables, and bunfig.toml validation.
Documentation
docs/runtime/environment-variables.mdx
Documented the new BUN_CONFIG_ELIDE_LINES environment variable, its default value, and precedence behavior with the --elide-lines CLI argument.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description explains the feature and references related issues, but does not follow the template structure which requires 'What does this PR do?' and 'How did you verify your code works?' sections. Reformat description to match template: add 'What does this PR do?' and 'How did you verify your code works?' sections with detailed information.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'cli: add BUN_CONFIG_ELIDE_LINES env var' clearly summarizes the main change—introducing a new environment variable for configuring elide-lines behavior.
Linked Issues check ✅ Passed The PR fully implements the feature requested in #11465: adds environment variable configuration for elide-lines limit, centralizes parsing with proper precedence, validates input in bunfig.zig, and includes comprehensive tests.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing BUN_CONFIG_ELIDE_LINES: environment variable definition, argument parsing, bunfig validation, documentation, and tests—no out-of-scope modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/cli/Arguments.zig`:
- Around line 477-479: The code duplicates environment-variable fallback logic
for BUN_CONFIG_ELIDE_LINES in two places; consolidate by extracting a single
helper (e.g., getElideLinesFromEnv or parseElideLines) and call it from both
parsing locations instead of repeating the logic. Locate and update usages that
set ctx.bundler_options.elide_lines and the CLI `--elide-lines` parsing to read
from that helper so the env var handling
(bun.env_var.BUN_CONFIG_ELIDE_LINES.get()) and int casting (`@intCast`) are
implemented once and returned/assigned consistently.
- Line 478: The assignment using `@intCast` to set ctx.bundler_options.elide_lines
from BUN_CONFIG_ELIDE_LINES.get() can overflow on 32-bit platforms; change the
code to validate or clamp the u64 value before casting (e.g., compare against
maxInt(usize) or use `@min` to clamp) and then set ctx.bundler_options.elide_lines
to the safely-cast ?usize; update the site around
ctx.bundler_options.elide_lines and the call to BUN_CONFIG_ELIDE_LINES.get() to
perform this check/clamp instead of a direct `@intCast`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6deec515-7f94-491d-8513-32b5827d7558

📥 Commits

Reviewing files that changed from the base of the PR and between 49221ca and 2983c9dc04d9184487ff22570a1a8654996b847d.

📒 Files selected for processing (4)
  • docs/runtime/environment-variables.mdx
  • src/cli/Arguments.zig
  • src/env_var.zig
  • test/cli/run/filter-workspace.test.ts

Comment thread src/cli/Arguments.zig Outdated
Comment thread src/cli/Arguments.zig Outdated
Comment thread src/cli/Arguments.zig Outdated
@alii

alii commented Apr 8, 2026

Copy link
Copy Markdown
Member Author

@robobun adopt

@robobun

robobun commented Apr 8, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Feature complete and MERGEABLE (rebased onto latest main, reimplemented in Rust, LGTM from review, 58/58 local tests pass, gate verified).

🟡 Build #59204: the only red lane is :windows: 11 aarch64 - test-bun shard 6, on test/cli/install/bun-install-security-provider.test.ts > Large payload via ipc pipe > handles packages JSON larger than max arg length (>1MB) — a 120s timeout (exit 143 = SIGTERM) in the security-scanner IPC path. 4 retries all timed out; this is a known-heavy IPC test that is slow/flaky on the Windows-aarch64 runner. 68/73 steps green.

This PRs diff is 5 files — src/bun_core/env_var.rs, src/runtime/cli/Arguments.rs, src/bunfig/bunfig.rs, docs/runtime/environment-variables.mdx, test/cli/run/filter-workspace.test.ts — and touches nothing in install, IPC, the security scanner, or the test harness. The failure is unrelated infrastructure flake, not this change.

@alii — diff is green on every relevant lane; the single failure is a Windows-aarch64 IPC-timeout flake. Ready to merge (or re-run that one lane).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/cli/filter_run.zig`:
- Around line 559-563: The current check rejects any explicit --elide-lines
value in non-terminal output even when the value is 0 (which is a no-op). Change
the guard so that when not pretty_output you only fail for an explicit
CLI-supplied positive value: check ctx.bundler_options.elide_lines is non-null
AND ctx.bundler_options.elide_lines != 0 AND
ctx.bundler_options.elide_lines_from_cli_flag is true, and only then call
Output.prettyErrorln(...) and Global.exit(1); leave the path that allows
elide_lines == 0 to continue normally.

In `@test/cli/run/filter-workspace.test.ts`:
- Around line 570-653: Add a regression test that mirrors
"BUN_CONFIG_ELIDE_LINES is silently ignored in non-terminal environments" but
supplies the elide-lines setting via a bunfig.toml (run.elide-lines) instead of
the BUN_CONFIG_ELIDE_LINES env var; create a tempDirWithFiles workspace that
includes a bunfig.toml with run.elide-lines = 17, invoke spawnSync with env: {
...bunEnv } and stdout/stderr piped (same invocation as the existing test using
bunExe(), spawnSync, and bunEnv), and assert stderr does not contain the
"--elide-lines is only supported" message, stdout contains the log lines, and
exitCode is 0 so the bunfig-backed code path (run.elide-lines) is covered and
treated as a silent no-op in non-terminal environments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a637b11f-9be1-4a0d-9a47-a10c1704ec50

📥 Commits

Reviewing files that changed from the base of the PR and between 2983c9dc04d9184487ff22570a1a8654996b847d and 117da3084c5f3bc1273e329648155837558014ec.

📒 Files selected for processing (4)
  • src/cli.zig
  • src/cli/Arguments.zig
  • src/cli/filter_run.zig
  • test/cli/run/filter-workspace.test.ts

Comment thread src/cli/filter_run.zig Outdated
Comment thread test/cli/run/filter-workspace.test.ts
Comment thread src/cli/filter_run.zig Outdated
Comment thread docs/runtime/environment-variables.mdx Outdated
Comment thread src/cli/Arguments.zig Outdated
Comment thread test/cli/run/filter-workspace.test.ts Outdated
Comment thread src/bunfig.zig Outdated

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All previously reported bugs have been addressed across the follow-up commits.

Extended reasoning...

Overview

The PR adds BUN_CONFIG_ELIDE_LINES as an env-var equivalent of --elide-lines, touching src/env_var.zig, src/cli.zig, src/cli/Arguments.zig, src/cli/filter_run.zig, src/bunfig.zig, docs, and tests.

Security risks

None — the new env var feeds into a usize display-count with no security surface.

Level of scrutiny

Medium. The changes are well-scoped feature additions to CLI argument parsing. All code paths have corresponding test coverage including the non-terminal/CI edge cases.

Other factors

I found several bugs in earlier rounds (missing CLI-origin flag, broken --elide-lines 0 in non-terminal, f64 boundary off-by-one in bunfig, Windows test branch mismatch). All were resolved in commits 117da30, e203746, and b333e0f/2cc006e. The diff and test file confirm the fixes are in place. No new bugs were found by the bug hunting system.

@robobun
robobun force-pushed the claude/bun-config-elide-lines-env branch from b333e0f to 1fdd3bb Compare April 8, 2026 04:18

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all previously raised issues have been resolved.

Extended reasoning...

Overview

This PR adds BUN_CONFIG_ELIDE_LINES as an env-var equivalent of --elide-lines, wiring it through src/env_var.zig, src/cli/Arguments.zig, src/cli/filter_run.zig, src/bunfig.zig, docs, and tests. The scope is moderate: 7 files, all within the CLI/config layer.

Security risks

None. The feature only controls how many lines of script output are shown in terminal environments; it doesn't touch auth, crypto, or I/O paths.

Level of scrutiny

Medium. The logic is self-contained and the test coverage is thorough, including platform-specific branches (Windows non-terminal), env-var vs CLI precedence, and bunfig fallback. All the bugs I flagged across prior runs have been addressed.

Other factors

The one remaining nit (fractional floats in bunfig silently truncating) is filed as an inline comment on this review. It is cosmetic — values like 5.7 become 5 instead of emitting a parse error — and does not affect correctness for the common case.

Comment thread src/cli/bunfig.zig
@robobun
robobun force-pushed the claude/bun-config-elide-lines-env branch from 761b247 to ce72069 Compare April 8, 2026 09:06
Comment thread test/cli/run/filter-workspace.test.ts Outdated
Comment thread src/cli/Arguments.zig Outdated

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all previously raised issues have been resolved.

Extended reasoning...

Overview

This PR adds BUN_CONFIG_ELIDE_LINES as a global environment-variable equivalent of --elide-lines, touching src/env_var.zig, src/cli.zig, src/cli/Arguments.zig, src/cli/filter_run.zig, src/bunfig.zig, docs, and tests.

Security risks

No security-sensitive code is touched. The new env var is a non-privileged numeric setting, parsed safely via std.math.cast with a clamp rather than a raw @intCast.

Level of scrutiny

Moderate — this is a feature addition to CLI argument parsing and runtime behavior, not a sandbox or config-only change. The core logic change (distinguishing CLI-sourced values from env var / bunfig sources via elide_lines_from_cli_flag) has been iterated on multiple times.

Other factors

Every specific issue from prior review rounds has been addressed in the follow-up commits (fractional-value guard with value \!= @floor(value), upper-bound fix to >=, Windows test branch condition tightened to elideLines \!== undefined && elideLines > 0, bunfig test passing -c ./bunfig.toml, empty-string CLI flag falling through to env var, docs semantics corrected). The final code state is correct and the test coverage is thorough.

@robobun
robobun force-pushed the claude/bun-config-elide-lines-env branch from c64951f to 0e9c158 Compare April 8, 2026 14:37

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all previously raised issues have been addressed: the non-terminal no-op, the silent-ignore for non-CLI sources, the bunfig boundary and fractional-value rejection, the vacuous bunfig test, and the empty env-var fallback.

Extended reasoning...

Overview

Adds as an env-var equivalent of , wires up precedence (CLI > env var > bunfig), documents the new variable, and adds comprehensive tests. Touches , , , , , , and .

Security risks

None. No auth, crypto, or permission-sensitive code is involved. The new env var is a purely additive output-formatting option.

Level of scrutiny

Moderate. The change is self-contained within the CLI run/filter path, but it required several iterations to get the edge cases right (empty-string expansion, , bunfig float boundary, non-terminal CI behavior). All those edge cases are now covered by tests and have been verified against the current source.

Other factors

Five follow-up commits (, , , , ) addressed every issue raised in prior reviews (mine and CodeRabbit's). The bug-hunting system found no new issues. Test coverage is thorough: terminal vs. non-terminal, env-var vs. CLI precedence, empty flag, bunfig fractional rejection, and Windows-branch behavior.

@alii

alii commented Apr 9, 2026

Copy link
Copy Markdown
Member Author

@robobun rebase

@robobun
robobun force-pushed the claude/bun-config-elide-lines-env branch from 0e9c158 to 757c840 Compare April 9, 2026 21:19

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all previously identified bugs have been resolved.

Extended reasoning...

Overview

This PR adds BUN_CONFIG_ELIDE_LINES as an environment-variable equivalent of --elide-lines for bun run --filter, touching src/env_var.zig, src/cli/Arguments.zig, src/bunfig.zig, docs, and tests.

Security risks

None. The change reads a user-controlled env var and parses it as an unsigned integer with explicit bounds checking. No auth, crypto, or permission-sensitive paths are affected.

Level of scrutiny

The scope is narrow and self-contained: a new env var definition, a consolidated parse helper, one new bunfig validation block, a docs entry, and test additions. The logic changes are all in CLI/config parsing, not in any hot runtime path.

Other factors

Multiple rounds of review caught several real bugs (32-bit cast overflow, non-terminal error firing for env-var-sourced values, fractional bunfig values, empty-flag shadowing the env var, bounds-check off-by-one). All have been addressed in subsequent commits. The final diff reflects correct behavior: safe casting, proper float validation with value \!= @floor(value) and >= upper bound, and the empty-string fallback in parseElideLinesOption. Test coverage is thorough, including the Windows non-terminal path. No new bugs were flagged by the bug hunting system.

@robobun
robobun force-pushed the claude/bun-config-elide-lines-env branch from 757c840 to 71ad395 Compare April 9, 2026 23:07

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all prior feedback was addressed: the non-terminal error guard was cleanly removed (making --elide-lines a graceful no-op when output is piped), bunfig.zig now validates fractional/negative/out-of-range values before @intFromFloat, the empty-string CLI flag correctly falls back to BUN_CONFIG_ELIDE_LINES, and 32-bit overflow is handled with std.math.cast.

Extended reasoning...

Overview

PR adds BUN_CONFIG_ELIDE_LINES as a global env-var equivalent of --elide-lines, touching src/env_var.zig, src/cli/Arguments.zig, src/bunfig.zig, docs, and tests. The CLI flag (or a non-empty expansion of it) takes precedence; an empty flag value falls back to the env var.

Prior bugs — all resolved

Multiple rounds of review produced five distinct bug reports from previous runs; every one is addressed in the final state:

  • Non-terminal error on env-var path: The --elide-lines is only supported in terminal environments guard in filter_run.zig was removed entirely rather than gated by a _from_cli_flag boolean; --elide-lines is now a silent no-op when pretty_output is false (the redraw() early return handles it).
  • --elide-lines 0 erroring in CI: Subsumed by the guard removal above.
  • bunfig unsafe @intFromFloat: The new guard checks value < 0, !isFinite, value != @floor(value), and value >= @floatFromInt(maxInt(usize)) before converting.
  • 32-bit @intCast panic: Uses std.math.cast(usize, value) orelse std.math.maxInt(usize).
  • Empty --elide-lines "" shadowing env var: parseElideLinesOption normalises empty string to null before the else if env-var branch.

Security risks

None. No auth, crypto, or permission-sensitive code is touched.

Scrutiny level

Medium-complexity CLI/config change (5 files). All previously identified bugs were fixed and the test suite covers the new code paths. Appropriate to approve.

@alii

alii commented Apr 14, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@robobun
robobun force-pushed the claude/bun-config-elide-lines-env branch from 2bfd715 to 64c1881 Compare April 17, 2026 23:06
@alii
alii enabled auto-merge (squash) April 17, 2026 23:35

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all previously raised concerns (empty-flag env-var fallback, 32-bit cast safety, bunfig fractional/bounds validation, non-terminal guard for env-var path, Windows test expectations) have been addressed.

Extended reasoning...

Overview

This PR adds BUN_CONFIG_ELIDE_LINES as a global env-var alternative to --elide-lines when using bun run --filter. It touches src/env_var.zig (new env var definition), src/cli/Arguments.zig (refactored into parseElideLinesOption), src/bunfig.zig (validation for run.elide-lines), and tests/docs.

Security risks

None. This is a display-control feature with no auth, file system, or network implications.

Level of scrutiny

Medium — Zig integer-casting edge cases were a concern, but the implementation uses std.math.cast(usize, value) orelse std.math.maxInt(usize) and a thorough bunfig.zig guard (negative, non-finite, fractional, out-of-range with >= boundary). All edge cases identified in earlier review rounds were fixed.

Other factors

Three rounds of iterative fixes addressed every issue I raised: the env-var-in-non-terminal false-error, empty-string flag shadowing the env var, 32-bit overflow, fractional bunfig values, and the Windows test branch expecting the wrong outcome for --elide-lines 0. The bug hunting system found no new issues in the final state.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all prior feedback has been addressed and the feature is cleanly implemented.

Extended reasoning...

Overview

This PR adds BUN_CONFIG_ELIDE_LINES as a global env-var equivalent of --elide-lines across five files: docs, src/env_var.zig, src/cli/Arguments.zig, src/bunfig.zig, and the filter-workspace test.

Security risks

None. The new code reads a numeric env var and a TOML number; both paths are validated before any cast.

Level of scrutiny

Low. The change is additive and self-contained: a new env var declaration, a consolidated parse helper, TOML validation, documentation, and tests. No auth, crypto, or IPC paths are touched.

Other factors

All issues raised in previous review rounds have been resolved in subsequent commits: the terminal-only fatal error was removed (making --elide-lines and BUN_CONFIG_ELIDE_LINES silently no-ops in non-TTY contexts), the bunfig.zig bounds check uses >= and guards fractional values, the empty-string CLI fallback is handled correctly, and the Windows test branch was updated to match. No bugs were found by the bug-hunting system.

@Jarred-Sumner
Jarred-Sumner force-pushed the claude/bun-config-elide-lines-env branch from 1ad2fe6 to 7839576 Compare May 4, 2026 10:38

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — all prior feedback addressed; the remaining inline note is a nit about test construction that doesn't affect correctness.

Extended reasoning...

Overview

This PR adds BUN_CONFIG_ELIDE_LINES as an env-var equivalent of --elide-lines for bun run --filter. It touches five files: a one-line declarative entry in src/bun_core/env_var.zig, a one-row docs table addition, a refactor in src/cli/Arguments.zig that consolidates two duplicate --elide-lines parsing blocks into a single parseElideLinesOption helper (with env-var fallback and safe std.math.cast clamping), input validation for run.elide-lines in src/cli/bunfig.zig (rejecting negative/non-finite/fractional/out-of-range floats before @intFromFloat), and four new tests in test/cli/run/filter-workspace.test.ts.

Security risks

None. This only affects how many lines of script output are displayed when running workspace scripts with --filter. No auth, crypto, network, file-permission, or untrusted-input handling is involved.

Level of scrutiny

Low-to-moderate. The PR went through several iterations and every substantive issue I (and CodeRabbit) raised earlier — the non-terminal error semantics, the misleading docs wording, the @intFromFloat panic on negative/oversized bunfig values, the missing fractional check, the > vs >= upper-bound off-by-one, the empty --elide-lines "" shadowing the env var, and the duplicated parsing logic — has been addressed and the inline comments are all resolved. The helper now runs after loadConfigWithCmdArgs, so CLI > env var > bunfig precedence is correct, and the bunfig guard is well-commented. CI build #46620 is green.

Other factors

The one remaining finding is a nit: the new fractional-rejection test passes -c and ./bunfig.toml as separate argv tokens, which (because -c is takes_value=.one_optional) doesn't consume the path and dispatches as AutoCommand rather than RunCommand. The test is not vacuous — the cwd auto-load still picks up bunfig.toml and the new validation in bunfig.zig fires exactly as asserted — only the in-test comment about the mechanism is inaccurate. That doesn't block merge.

Comment thread test/cli/run/filter-workspace.test.ts Outdated
@alii

alii commented May 30, 2026

Copy link
Copy Markdown
Member Author

@robobun rebase and get this mergable

Split out from #18111 by @martinamps. Adds `BUN_CONFIG_ELIDE_LINES` as
an environment-variable equivalent of `--elide-lines`, so the limit can
be set once globally instead of per command. The CLI flag takes
precedence when both are set. Closes #11465.

Implemented against the Rust CLI (`src/runtime/cli/Arguments.rs`,
`src/bun_core/env_var.rs`, `src/bunfig/bunfig.rs`) after the src port:
- Consolidate the two duplicated `--elide-lines` parse blocks into a
  single `parse_elide_lines_option` helper, called after
  `load_config_with_cmd_args` so CLI + env var beat `run.elide-lines`
  in bunfig.toml.
- Empty `--elide-lines ""` (e.g. `--elide-lines "$MAYBE_UNSET"`) falls
  through to the env var instead of shadowing it.
- Env var value is clamped via `usize::try_from(...).unwrap_or(usize::MAX)`
  so 32-bit targets don't lose high bits above `usize::MAX`.
- `bunfig.rs` rejects negative, non-finite, fractional, and out-of-range
  `run.elide-lines` numbers with `Expected a non-negative integer`
  instead of silently saturating/truncating via `as usize`.

Tests cover CLI vs env-var precedence, the empty-string fallback, the
bunfig fractional rejection, and the non-terminal no-op contract. The
bunfig test uses `--config=./bunfig.toml` (`=` form) because clap's
`.one_optional` does not consume a following argv element.
@robobun
robobun force-pushed the claude/bun-config-elide-lines-env branch from f387db6 to a3a7bb2 Compare May 30, 2026 09:43

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — small, well-tested env-var addition; all prior review feedback has been addressed in the Rust port.

Extended reasoning...

Overview

This PR adds BUN_CONFIG_ELIDE_LINES as an environment-variable equivalent of the --elide-lines CLI flag for bun run --filter. It touches five files: a one-line env-var declaration in env_var.rs, a small parse_elide_lines_option helper in Arguments.rs that consolidates two previously-duplicated parse blocks (CLI flag → env var fallback, with empty-string passthrough and usize::try_from clamping), input validation for run.elide-lines in bunfig.rs (rejecting negative/non-finite/fractional/out-of-range), four new tests in filter-workspace.test.ts, and a one-line docs entry.

Security risks

None. This controls how many lines of subprocess output are shown in the terminal during bun run --filter — a pure display preference with no auth, crypto, network, filesystem, or privilege implications.

Level of scrutiny

Low-to-medium. The change is small, mechanical, and follows established patterns (new! macro for env vars, existing CLI option parsing shape). Both removed elide-lines blocks and the single remaining call site are inside the same RunCommand | AutoCommand guard, and the consolidated call now correctly runs after load_config_with_cmd_args so CLI/env precedence over bunfig is preserved. The Rust as cast in bunfig.rs saturates rather than panicking, so the boundary concern from the earlier Zig version no longer applies.

Other factors

This PR has been through extensive iteration (8+ rounds of bot review since April), and every prior inline comment is marked resolved in the current diff: doc wording corrected to "maximum number of lines shown", empty --elide-lines falls through to the env var, bunfig validation added with n.fract() != 0.0 check, the bunfig test uses the --config= form, and 32-bit clamping uses usize::try_from().unwrap_or(usize::MAX). The bug-hunting system found no issues in this revision. Tests cover env-var precedence, CLI override, empty-flag fallback, and bunfig fractional rejection.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuration for max lines when eliding filter output

2 participants