[PR #2140] [MERGED] fix(cli): report an invalid REA_LOG_LEVEL as configuration #5055

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2140
Author: @kaoru0822-kitauji
Created: 10/12/2026
Status: ✅ Merged
Merged: 10/12/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: fix/issue-2135


📝 Commits (1)

  • fe25f02 fix(cli): report an invalid REA_LOG_LEVEL as configuration

📊 Changes

5 files changed (+64 additions, -8 deletions)

View changed files

📝 scripts/rea.mjs (+7 -2)
📝 src/cli.ts (+17 -3)
📝 src/logger.ts (+18 -2)
➕ tests/boundary/cli/cliLogLevelConfiguration.test.ts (+21 -0)
📝 tests/boundary/cli/dispatcher.test.ts (+1 -1)

📄 Description

Summary

createCli parsed REA_LOG_LEVEL with a throwing Zod schema. An invalid or differently cased value (loud, INFO) therefore crashed every CLI command, including rea doctor and rea --help, with an uncaught ZodError stack trace. The MCP adapter already reports the same setting as a ConfigurationError.

  • parseLogLevel (src/logger.ts) now returns a Result carrying a ConfigurationError that names REA_LOG_LEVEL.
  • cliConfigurationError (src/cli.ts) renders that error with projectAnalysisError, the same message MCP prints. scripts/rea.mjs checks it before building the CLI and exits 1, as it already does for invalid output arguments.
  • createCli no longer throws. Embedders that call it directly get the silent default for an invalid level.

Fixes #2135

Before / after

$ REA_LOG_LEVEL=loud rea doctor --json
before: ZodError stack trace from parseLogLevel/createCli, exit 1
after:  REA configuration is invalid: REA_LOG_LEVEL: Invalid option: expected one of "trace"|"debug"|"info"|"warn"|"error"|"fatal"|"silent".   (stderr, exit 1)

Valid values and an unset REA_LOG_LEVEL behave as before.

Validation

  • New CLI boundary test tests/boundary/cli/cliLogLevelConfiguration.test.ts runs doctor --json and --help through the real scripts/rea.mjs with loud and INFO. It fails on main (stack trace) and passes with this change.
  • tests/boundary/cli/dispatcher.test.ts: its stub dist/cli-runtime/cli.js now also exports cliConfigurationError, matching the module's new export.
  • npm run lint passes.
  • npm test (before rebasing onto main): 9151 passed, 15 failed in 8 files. These are the same files and tests that fail on clean origin/main c22111eca on this host: Hopper, ibtool, hdiutil and inspector environment cases, plus promptCompletion, which main has since fixed in #2137. After rebasing, the dispatcher, log-level and promptCompletion tests pass.

🤖 Generated with Claude Code


🔄 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/2140 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/12/2026 **Status:** ✅ Merged **Merged:** 10/12/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/issue-2135` --- ### 📝 Commits (1) - [`fe25f02`](https://github.com/morluto/rea/commit/fe25f0288c3d5dbc0c791f3115b5849e51455dec) fix(cli): report an invalid REA_LOG_LEVEL as configuration ### 📊 Changes **5 files changed** (+64 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `scripts/rea.mjs` (+7 -2) 📝 `src/cli.ts` (+17 -3) 📝 `src/logger.ts` (+18 -2) ➕ `tests/boundary/cli/cliLogLevelConfiguration.test.ts` (+21 -0) 📝 `tests/boundary/cli/dispatcher.test.ts` (+1 -1) </details> ### 📄 Description ## Summary `createCli` parsed `REA_LOG_LEVEL` with a throwing Zod schema. An invalid or differently cased value (`loud`, `INFO`) therefore crashed every CLI command, including `rea doctor` and `rea --help`, with an uncaught `ZodError` stack trace. The MCP adapter already reports the same setting as a `ConfigurationError`. - `parseLogLevel` (`src/logger.ts`) now returns a `Result` carrying a `ConfigurationError` that names `REA_LOG_LEVEL`. - `cliConfigurationError` (`src/cli.ts`) renders that error with `projectAnalysisError`, the same message MCP prints. `scripts/rea.mjs` checks it before building the CLI and exits 1, as it already does for invalid output arguments. - `createCli` no longer throws. Embedders that call it directly get the silent default for an invalid level. Fixes #2135 ## Before / after ```text $ REA_LOG_LEVEL=loud rea doctor --json before: ZodError stack trace from parseLogLevel/createCli, exit 1 after: REA configuration is invalid: REA_LOG_LEVEL: Invalid option: expected one of "trace"|"debug"|"info"|"warn"|"error"|"fatal"|"silent". (stderr, exit 1) ``` Valid values and an unset `REA_LOG_LEVEL` behave as before. ## Validation - New CLI boundary test `tests/boundary/cli/cliLogLevelConfiguration.test.ts` runs `doctor --json` and `--help` through the real `scripts/rea.mjs` with `loud` and `INFO`. It fails on main (stack trace) and passes with this change. - `tests/boundary/cli/dispatcher.test.ts`: its stub `dist/cli-runtime/cli.js` now also exports `cliConfigurationError`, matching the module's new export. - `npm run lint` passes. - `npm test` (before rebasing onto main): 9151 passed, 15 failed in 8 files. These are the same files and tests that fail on clean `origin/main` c22111eca on this host: Hopper, ibtool, hdiutil and inspector environment cases, plus `promptCompletion`, which main has since fixed in #2137. After rebasing, the dispatcher, log-level and `promptCompletion` tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:01:12 +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#5055
No description provided.