[PR #2315] [MERGED] fix(cli): reject unterminated output filter slices #5160

Closed
opened 2026-10-31 01:04:25 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2315
Author: @maxazure
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/13/2026
Merged by: @morluto

Base: main ← Head: fix/cli-unclosed-output-filter


📝 Commits (1)

  • 7432801 fix(cli): reject unterminated output filter slices

📊 Changes

2 files changed (+118 additions, -3 deletions)

View changed files

📝 src/cliOutput.ts (+29 -3)
📝 tests/boundary/cli/cliOutput.test.ts (+89 -0)

📄 Description

Summary

rea providers --json --filter-output 'providers[' hangs without output. Reject unterminated filter slices before running the command, returning exit status 1 and an actionable INVALID_OUTPUT_FILTER error.

Found while testing CLI output parameters; no existing issue was identified for this failure.

Problem and expected behavior

Incur's filter parser does not advance when a path contains [ without a following ]. A stray closing bracket can also affect comma splitting: ][,] hangs even though a closing bracket appears later in the full expression.

Invalid output parameters should fail promptly. Representative JSON output after this change:

{"ok":false,"error":{"code":"INVALID_OUTPUT_FILTER","message":"The --filter-output expression has a slice without a closing ]. Close the slice or remove --filter-output."}}

Change and scope

Check slice termination at REA's executable output-argument boundary, following Incur's comma splitting. Preserve existing parsable expressions, the last effective repeated filter, and earlier builtin-flag errors. Reuse the existing error renderer across output formats.

This is an ordinary CLI parameter fix; a maintainer scope decision for new providers or execution capabilities is not applicable. Open #2293 changes failure envelopes and does not address filter parsing.

Contract and boundary impact

  • Owner and earliest changed stage: executable CLI output-argument admission, before command execution.

  • CLI: adds the error above for previously hanging inputs; MCP/tool schemas are unaffected.

  • Provider, target-format, Evidence/provenance, generated metadata, installation and package impact: none.

  • Target selection, execution authority and cleanup: no new target interaction; invalid filters are rejected before the command runs.

  • Documentation or usability only; no target interaction.

Evidence and regression coverage

On base bb2662267, the public compiled CLI timed out after 3 seconds with empty stdout/stderr for an unclosed slice. The new regression run failed with three parameter assertions and a timed-out CLI case; ten existing tests passed.

Coverage includes malformed multi-path filters, all five output formats, normal slicing, repeated flags and earlier flag-error precedence. A separate Codex agent review found the stray-] case, then verified the final CLI behavior and checked 488,281 short expressions against the pinned parser's progress rules without a mismatch.

Implemented and independently reviewed with Codex. No human review is claimed.

Validation performed

On macOS arm64, pinned Node 24.18.0 / npm 11.16.0, after updating to main d1aaeee40:

  • npm run test:focused -- tests/boundary/cli/cliOutput.test.ts tests/boundary/cli/dispatcher.test.ts — 20 passed.
  • npm run check — passed.
  • npm run verify:test-discovery — all 964 test files discovered exactly once.
  • git diff --cached --check and the normal pre-commit/pre-push hooks — passed.

Compatibility, safety, and release

No migration or release metadata change. Linux and Windows were not tested locally. No real Hopper, Ghidra or browser verification is claimed; this change does not alter those providers. The full deterministic suite remains for CI. The CI run for commit 7432801f2 returned action_required before any jobs started; CI verification is blocked on upstream action. No workflow approval was requested or performed.

Before merge

  • Concrete problem, one focused outcome and Conventional Commit title.
  • Scope and authority questions resolved within existing CLI boundaries.
  • Reason for no related issue stated above.
  • Tests cover observable behavior and meaningful failures; representative output included.
  • No authored schema, generated metadata or provider documentation update needed.
  • Final diff checked for secrets, unrelated cleanup and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2315 **Author:** [@maxazure](https://github.com/maxazure) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/13/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/cli-unclosed-output-filter` --- ### 📝 Commits (1) - [`7432801`](https://github.com/morluto/rea/commit/7432801f29968d671d65edb37a4d965904da6e9e) fix(cli): reject unterminated output filter slices ### 📊 Changes **2 files changed** (+118 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/cliOutput.ts` (+29 -3) 📝 `tests/boundary/cli/cliOutput.test.ts` (+89 -0) </details> ### 📄 Description ## Summary `rea providers --json --filter-output 'providers['` hangs without output. Reject unterminated filter slices before running the command, returning exit status 1 and an actionable `INVALID_OUTPUT_FILTER` error. Found while testing CLI output parameters; no existing issue was identified for this failure. ## Problem and expected behavior Incur's filter parser does not advance when a path contains `[` without a following `]`. A stray closing bracket can also affect comma splitting: `][,]` hangs even though a closing bracket appears later in the full expression. Invalid output parameters should fail promptly. Representative JSON output after this change: ```json {"ok":false,"error":{"code":"INVALID_OUTPUT_FILTER","message":"The --filter-output expression has a slice without a closing ]. Close the slice or remove --filter-output."}} ``` ## Change and scope Check slice termination at REA's executable output-argument boundary, following Incur's comma splitting. Preserve existing parsable expressions, the last effective repeated filter, and earlier builtin-flag errors. Reuse the existing error renderer across output formats. This is an ordinary CLI parameter fix; a maintainer scope decision for new providers or execution capabilities is not applicable. Open #2293 changes failure envelopes and does not address filter parsing. ## Contract and boundary impact - Owner and earliest changed stage: executable CLI output-argument admission, before command execution. - CLI: adds the error above for previously hanging inputs; MCP/tool schemas are unaffected. - Provider, target-format, Evidence/provenance, generated metadata, installation and package impact: none. - Target selection, execution authority and cleanup: no new target interaction; invalid filters are rejected before the command runs. - [x] Documentation or usability only; no target interaction. ## Evidence and regression coverage On base `bb2662267`, the public compiled CLI timed out after 3 seconds with empty stdout/stderr for an unclosed slice. The new regression run failed with three parameter assertions and a timed-out CLI case; ten existing tests passed. Coverage includes malformed multi-path filters, all five output formats, normal slicing, repeated flags and earlier flag-error precedence. A separate Codex agent review found the stray-`]` case, then verified the final CLI behavior and checked 488,281 short expressions against the pinned parser's progress rules without a mismatch. Implemented and independently reviewed with Codex. No human review is claimed. ## Validation performed On macOS arm64, pinned Node 24.18.0 / npm 11.16.0, after updating to main `d1aaeee40`: - `npm run test:focused -- tests/boundary/cli/cliOutput.test.ts tests/boundary/cli/dispatcher.test.ts` — 20 passed. - `npm run check` — passed. - `npm run verify:test-discovery` — all 964 test files discovered exactly once. - `git diff --cached --check` and the normal pre-commit/pre-push hooks — passed. ## Compatibility, safety, and release No migration or release metadata change. Linux and Windows were not tested locally. No real Hopper, Ghidra or browser verification is claimed; this change does not alter those providers. The full deterministic suite remains for CI. The [CI run for commit `7432801f2`](https://github.com/morluto/rea/actions/runs/38296208206) returned `action_required` before any jobs started; CI verification is blocked on upstream action. No workflow approval was requested or performed. ## Before merge - [x] Concrete problem, one focused outcome and Conventional Commit title. - [x] Scope and authority questions resolved within existing CLI boundaries. - [x] Reason for no related issue stated above. - [x] Tests cover observable behavior and meaningful failures; representative output included. - [x] No authored schema, generated metadata or provider documentation update needed. - [x] Final diff checked for secrets, unrelated cleanup and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:04:25 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5160
No description provided.