Skip to content

fix(cli)!: keep a selected JSON null in --filter-output output - #2333

Merged
morluto merged 1 commit into
morluto:mainfrom
Jackmeson1:fix/cli-filter-output-null
Oct 13, 2026
Merged

morluto merged 1 commit into
morluto:mainfrom
Jackmeson1:fix/cli-filter-output-null

Conversation

@Jackmeson1

@Jackmeson1 Jackmeson1 commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

The streamed JSON/JSONL path printed {} when --filter-output selected an explicit null, which is the same output
as a selection that does not exist. This keeps a selected null as null on that path, without --full-output or
--token-count. No separate issue was filed; this PR is the report.

Problem and expected behavior

Smallest trigger: in a fresh invocation without a bound analysis provider, node scripts/rea.mjs capabilities --json
returns "analysis_provider_binding": null. From a checkout of fd95880, run npm ci && npm run build:cached, then:

$ node scripts/rea.mjs capabilities --format json --filter-output analysis_provider_binding
{}
$ node scripts/rea.mjs capabilities --format json --filter-output no_such_field
{}

Violated invariant: AGENTS.md asks that omission and uncertainty survive boundaries, and the JSON writer already
preserves null (tests/boundary/cli/jsonOutput.test.ts). Incur's filter also preserves a selected null; the streamed
renderer then collapsed it to {}. renderEmptyFilteredCliOutput in src/cliOutput.ts is a separate fallback for an
Incur invocation that emitted no output; it does not inspect the selected value.

Change and scope

In src/cli/cliResultOutput.ts (createCliResultOutput), the non-envelope branch no longer maps null to
{}. This also preserves an unfiltered top-level null. undefined, functions and symbols still fall back to {}.
Not changed:

  • --full-output without --token-count, which already writes {"ok":true,"data":null,...} for a selected null;
  • --token-count, which still hands results that fit the formatted-string limit back to Incur. Incur 0.6.1 counts
    selected null as empty, so --token-count --filter-output analysis_provider_binding still prints 0;
  • other formats: the capabilities selection above still produces {} in YAML and no output in TOON/Markdown;
  • Incur-owned paths, including sentinel and generator results, and createCli calls without the streamed output
    surface. A selected null in a plain success sentinel still reaches the dispatcher's {} fallback in JSON/JSONL.

The fix uses the existing filter and JSON writer; it removes the intervening null-to-empty conversion. Changing
Incur's formatter, token counting, or sentinel/generator protocols is outside this streamed JSON/JSONL fix.

Contribution scope: an ordinary fix within the existing CLI output boundary. Not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: CLI JSON/JSONL rendering in createCliResultOutput, after
    optional --filter-output selection.
  • Contribution scope fit and linked maintainer decision: in scope as a fix. Not applicable.
  • CLI and MCP/tool-catalog contract: CLI only. A top-level null now prints null instead of {} on the streamed
    JSON/JSONL path described above. MCP is unchanged.
  • Provider, bridge, target-format, or platform compatibility: none.
  • Evidence, artifact, provenance, or reconstruction contract: none. Stored data is unchanged; only the CLI projection
    changes.
  • Target selection, authority, upstream behavior, and cleanup details: not applicable.
  • Generated metadata, package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: tests/boundary/cli/jsonOutput.test.ts, new describe block "streamed CLI filtered
    selections". It is a table over createCliResultOutput with:

    • a selected null in JSON and JSONL;
    • a nested selection containing null ({"nested":{"value":null}}, unchanged);
    • a missing selection ({});
    • 0 and false.
  • Base reproduction, executed outside the sandbox and repeated in the sandbox: with only the test applied on
    fd95880, the two selected-null rows fail with
    expected '{}\n' to be 'null\n'. The other four pass.

  • User-visible CLI output, after npm run build:cached with this change:

    $ node scripts/rea.mjs capabilities --format json --filter-output analysis_provider_binding
    null
    $ node scripts/rea.mjs capabilities --format jsonl --filter-output analysis_provider_binding
    null
    $ node scripts/rea.mjs capabilities --format json --filter-output no_such_field
    {}
    
  • Remaining proof gaps: the Incur-owned paths above retain their existing behavior. The sandbox could not complete
    artifact preparation or the full static gate; related compiled tests failed on both revisions as recorded below.
    Validation with the repository-pinned Node/npm versions remains outstanding.

  • Evidence-bearing changes: stored Evidence and provenance are unchanged; only the CLI projection changes.

Validation performed

Outside-sandbox validation on WSL Ubuntu 22.04 with the repository-pinned Node 24.18.0 and npm 11.16.0. Rebased
commit on base fd95880, which renamed streamedJsonOutput.ts to cliResultOutput.ts:

  • npm run check — passed (typecheck, lint, format:check, knip, metadata:check and the architecture guards)
  • npx vitest run tests/boundary/cli/jsonOutput.test.ts — 41 passed. On fd95880 with only the new test applied,
    the two selected-null rows fail as described above.
  • npm run test:prepare && npx vitest run --project cli-boundary — 316 passed, 21 skipped, 2 failed. Both failures
    are in tests/boundary/cli/referenceSourceImportStatus.test.ts (the --full-output preflight cases, which expect
    ok: true and get ok: false), and they fail identically on fd95880 without this change.
  • npx vitest run tests/acceptance/managedCliOutput.test.ts — 7 passed
  • node scripts/rea.mjs capabilities ... --filter-output ... with the built CLI on fd95880 and on this branch —
    output shown above

Before the rebase, on base a97b713: the same npm run check passed, and cliOutput, dispatcher,
javascriptApplicationJsonOutput, managedCliOutput and jsonOutput passed together (61 tests). Independent
checks in a disposable sandbox copy (Node 24.21.0, npm 11.19.0) also passed there: tsc --noEmit, oxlint and
oxfmt --check on the changed files, npm run verify:test-discovery, and the built-CLI comparison across JSON/JSONL,
missing field, --token-count, --full-output, YAML and TOON/Markdown. In that sandbox, npm run check and the
compiled CLI tests could not run (spawnSync ... EPERM); the outside-sandbox runs cover them.

Compatibility, safety, and release

  • Breaking changes or migration steps: capabilities --format json --filter-output analysis_provider_binding
    previously returned {} when the field was null; the streamed JSON/JSONL path now returns null. Consumers must
    accept JSON null for a present null and distinguish it from a missing selection. Use --full-output if an object
    envelope is required. Keeping the old shared {} representation would continue hiding this distinction.
  • Real Hopper/Ghidra, browser, or OS coverage: CLI validation was on WSL/Linux only; real providers were not
    exercised and are not required for this formatting change.
  • Package or release metadata impact: no manual version or CHANGELOG edit. The ! title marks the compatibility
    change for Release Please; the migration is described above.
  • Security, privacy, process, or containment review: not applicable.

AI disclosure: prepared with AI assistance (Claude Code); the checks above were run before opening the PR.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.
  • Complete npm run check with the pinned Node 24.18.0/npm 11.16.0 and rerun the relevant compiled tests outside
    the restricted sandbox.

🤖 Generated with Claude Code

https://claude.ai/code/session_019TTGAv6fe859ebbCLLfLHP

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

createCliResultOutput rendered an explicit null selected by
--filter-output as the empty document {}, the same output it uses when
the selection has no value at all. On the streamed JSON/JSONL path,
a consumer could not distinguish a selected null from a missing field.

Write a selected null as null in streamed JSON and JSONL. This also
preserves an unfiltered top-level null. The {} fallback stays for
undefined, functions and symbols. The --full-output envelope already
carried data: null for a selected null. The --token-count path still
hands results that fit the formatted-string limit back to Incur and
prints 0 for a selected null. Other formats and Incur-owned result
paths are unchanged.

Consumers must accept JSON null for a present null and distinguish it
from a missing selection. Use --full-output if an object envelope is
required. Keeping the old shared {} representation would continue
hiding this distinction.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_019TTGAv6fe859ebbCLLfLHP
@Jackmeson1
Jackmeson1 force-pushed the fix/cli-filter-output-null branch from 546c3f1 to ab96bc8 Compare October 12, 2026 20:30
@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: CI had not run on this head when I tested it, so this is the first run of it. On Linux with Node 22, 24 and 26, a selected null now prints null in JSON and JSONL. Everything else I checked printed the same as before.

Results

I compared head (ab96bc8) with its parent (fd95880). Only this PR's two files differ. Every result was the same on Node 22, 24 and 26.

Check Base Head
Selected null: --format json, jsonl, --json {} null
Missing field {} {}
Selected false false false
  • Nested nulls, two nulls, YAML, TOON, Markdown, --full-output and --token-count print the same on base and head.
  • Your test file passes on head. On base, only the two raw_result rows fail: expected '{}\n' to be 'null\n'.
  • Four test files, 66 tests, pass on head.
  • The bare-null case holds in code: createCliResultOutput with a bare null prints null on head. I found no normal command that returns a bare null.

Not run

  • About 130 commands that need a target file, a device or a process.
  • dispatcher.test.ts. It names the doctor command, and my test rules skip any file that does.
  • npm run check and the full cli-boundary project. Windows and macOS.

Thanks, Jackmeson1, for a small fix with a test that fails on base the way you described.

More details
  • On this box analysis_provider_binding is null, as you said. So are analysis_run and provider_operation_health.
  • Every CLI command exited 0, except the apktool and JEB client checks. Those exit 1 on both trees.
  • Five commands print the same on both trees: capabilities, providers and three client checks.
  • An aside, outside this PR: --token-count prints 0 for a selected null and for a missing field alike.
Commands
npm ci && npm run build && npm run test:prepare      # each tree, Node 24.18.0
node scripts/rea.mjs capabilities --format json --filter-output analysis_provider_binding
node scripts/rea.mjs capabilities --format jsonl --filter-output analysis_provider_binding
node scripts/rea.mjs capabilities --format json --filter-output no_such_field
node scripts/rea.mjs capabilities --format yaml --filter-output analysis_provider_binding
node scripts/rea.mjs capabilities --format json --full-output --filter-output analysis_provider_binding
node scripts/rea.mjs capabilities --format json --token-count --filter-output analysis_provider_binding
npm run test:focused -- tests/boundary/cli/jsonOutput.test.ts tests/acceptance/managedCliOutput.test.ts tests/boundary/cli/cliOutput.test.ts tests/boundary/cli/javascriptApplicationJsonOutput.test.ts

Each CLI command ran on base and head under Node 22, 24 and 26. The test run used each Node in turn. For the base check I copied your jsonOutput.test.ts into the base tree and ran test:focused on that one file.

Test setup
  • Box: Nobara 44 (Fedora 44 base), Linux 7.2.9
  • CPU: AMD Ryzen 9 5900X, 12 cores / 24 threads
  • RAM: 32 GB DDR4-3600
  • Node: 22.23.1, 24.18.0, 26.11.1
  • Head: ab96bc8
  • Base: fd95880
  • Other: GitHub lists the base as 4dd44dd, three commits later. They touch none of these files. Another test agent shared the box. HOME was an empty scratch folder for the test runs.

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

This PR is set for a Plus review. TREX isn't supported with Plus or Apex reviews yet, so Greptile reviews this PR at Base while TREX is on.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

The streamed JSON/JSONL output now keeps a selected null instead of replacing it with {}.

  • Filtered JSON keeps a selected null as null.

Reviews (1) · Last reviewed commit: "fix(cli)!: keep a selected JSON null in ..." · Reviewed by Greptile

@morluto
morluto merged commit 1ca5fd3 into morluto:main Oct 13, 2026
1 check passed
@greptile-apps greptile-apps Bot mentioned this pull request Oct 13, 2026
3 tasks done
@morluto morluto added bug Something isn't working area: cli CLI adapter and one-shot commands labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants