[PR #1199] [MERGED] fix(config): name the rejected setting and its constraint in configuration errors #2712

Closed
opened 2026-10-17 21:09:22 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/config-error-names-setting


📝 Commits (1)

  • 0a0244d fix(config): name the rejected setting and its constraint in configuration errors

📊 Changes

9 files changed (+145 additions, -14 deletions)

View changed files

📝 src/config.test.ts (+43 -0)
📝 src/config/environment.ts (+6 -0)
📝 src/config/mcpResponseBudget.ts (+10 -3)
📝 src/config/parsers.ts (+28 -2)
📝 src/domain/analysisErrorPresentation.ts (+11 -1)
📝 src/domain/analysisErrorProjection.ts (+11 -1)
📝 src/domain/configurationErrors.ts (+18 -0)
📝 src/ida/IdaConfiguration.ts (+15 -5)
📝 src/ida/IdaProvider.ts (+3 -2)

📄 Description

Summary

Every configuration failure was projected with the same text, "REA configuration is invalid. Run rea doctor and fix the reported setting.", and no details. The environment parser had the exact issue (REA_GHIDRA_NATIVEAOT_JAR must be absolute, GHIDRA_INSTALL_DIR must be absolute, …) but dropped it. Doctor, which the message points to, can report Ghidra healthy for the same environment (#1183). So neither the CLI, the MCP server's startup stderr, nor doctor told the caller which setting to correct.

Fixes #1184

Change

  • ConfigurationError (src/domain/configurationErrors.ts) carries settings: { setting, constraint }[]. Values are never stored, since settings such as REA_REFERENCE_SECRET_PATTERNS_JSON may hold sensitive patterns.
  • The sources fill it in:
    • parseEnvironment maps each zod issue to its variable name and message. These messages name the constraint, not the value.
    • The JSON setting parsers, REA_MCP_MAX_RESPONSE_BYTES, and the REA_IDA_MCP_CONFIG registration errors (through a small idaConfigurationError helper) name their setting.
  • Projection: the message lists the constraints (REA configuration is invalid: GHIDRA_INSTALL_DIR must be absolute; JAVA_HOME must be absolute.). details.settings lists each setting and constraint. Remediation asks the caller to correct the named settings in the environment that starts REA (shell or MCP client registration), then rerun. A ConfigurationError without settings keeps the previous message.

Built CLI / MCP

{"code":"configuration_invalid",
 "message":"REA configuration is invalid: REA_GHIDRA_NATIVEAOT_JAR must be absolute.",
 "remediation":{"action":"Correct REA_GHIDRA_NATIVEAOT_JAR in the environment that starts REA (your shell or the MCP client's registration), then rerun."},
 "details":{"settings":[{"setting":"REA_GHIDRA_NATIVEAOT_JAR","constraint":"REA_GHIDRA_NATIVEAOT_JAR must be absolute"}]}}

GHIDRA_INSTALL_DIR=./fixture rea mcp now prints REA configuration is invalid: GHIDRA_INSTALL_DIR must be absolute. to stderr and exits 1.

Tests

src/config.test.ts (configuration failure diagnostics):

  • relative GHIDRA_INSTALL_DIR, JAVA_HOME, and REA_GHIDRA_NATIVEAOT_JAR each project the setting, constraint, message, and remediation, and the rejected value is not echoed;
  • an invalid HOPPER_LOADER_ARGS_JSON names its setting.

All four fail on main.

Verification

  • npm run check:fast, npm run jscpd
  • npm run test:focused -- every test touching ConfigurationError, configuration_invalid, parseConfig, IDA configuration, or the MCP response budget (14 files, 173 passed)
  • Built CLI (providers, capabilities) and rea mcp startup, as above

This covers the error-message half of the problem. #1183 (doctor and setup accepting a relative GHIDRA_INSTALL_DIR) is a separate change.

🤖 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/1199 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/9/2026 **Status:** ✅ Merged **Merged:** 10/9/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `fix/config-error-names-setting` --- ### 📝 Commits (1) - [`0a0244d`](https://github.com/morluto/rea/commit/0a0244db4212bc1f59dec4b925fa90b3b473136a) fix(config): name the rejected setting and its constraint in configuration errors ### 📊 Changes **9 files changed** (+145 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/config.test.ts` (+43 -0) 📝 `src/config/environment.ts` (+6 -0) 📝 `src/config/mcpResponseBudget.ts` (+10 -3) 📝 `src/config/parsers.ts` (+28 -2) 📝 `src/domain/analysisErrorPresentation.ts` (+11 -1) 📝 `src/domain/analysisErrorProjection.ts` (+11 -1) 📝 `src/domain/configurationErrors.ts` (+18 -0) 📝 `src/ida/IdaConfiguration.ts` (+15 -5) 📝 `src/ida/IdaProvider.ts` (+3 -2) </details> ### 📄 Description ## Summary Every configuration failure was projected with the same text, "REA configuration is invalid. Run `rea doctor` and fix the reported setting.", and no `details`. The environment parser had the exact issue (`REA_GHIDRA_NATIVEAOT_JAR must be absolute`, `GHIDRA_INSTALL_DIR must be absolute`, …) but dropped it. Doctor, which the message points to, can report Ghidra healthy for the same environment (#1183). So neither the CLI, the MCP server's startup stderr, nor doctor told the caller which setting to correct. Fixes #1184 ## Change - `ConfigurationError` (`src/domain/configurationErrors.ts`) carries `settings: { setting, constraint }[]`. Values are never stored, since settings such as `REA_REFERENCE_SECRET_PATTERNS_JSON` may hold sensitive patterns. - The sources fill it in: - `parseEnvironment` maps each zod issue to its variable name and message. These messages name the constraint, not the value. - The JSON setting parsers, `REA_MCP_MAX_RESPONSE_BYTES`, and the `REA_IDA_MCP_CONFIG` registration errors (through a small `idaConfigurationError` helper) name their setting. - Projection: the message lists the constraints (`REA configuration is invalid: GHIDRA_INSTALL_DIR must be absolute; JAVA_HOME must be absolute.`). `details.settings` lists each setting and constraint. Remediation asks the caller to correct the named settings in the environment that starts REA (shell or MCP client registration), then rerun. A `ConfigurationError` without settings keeps the previous message. ## Built CLI / MCP ```json {"code":"configuration_invalid", "message":"REA configuration is invalid: REA_GHIDRA_NATIVEAOT_JAR must be absolute.", "remediation":{"action":"Correct REA_GHIDRA_NATIVEAOT_JAR in the environment that starts REA (your shell or the MCP client's registration), then rerun."}, "details":{"settings":[{"setting":"REA_GHIDRA_NATIVEAOT_JAR","constraint":"REA_GHIDRA_NATIVEAOT_JAR must be absolute"}]}} ``` `GHIDRA_INSTALL_DIR=./fixture rea mcp` now prints `REA configuration is invalid: GHIDRA_INSTALL_DIR must be absolute.` to stderr and exits 1. ## Tests `src/config.test.ts` (`configuration failure diagnostics`): - relative `GHIDRA_INSTALL_DIR`, `JAVA_HOME`, and `REA_GHIDRA_NATIVEAOT_JAR` each project the setting, constraint, message, and remediation, and the rejected value is not echoed; - an invalid `HOPPER_LOADER_ARGS_JSON` names its setting. All four fail on `main`. ## Verification - `npm run check:fast`, `npm run jscpd` - `npm run test:focused --` every test touching `ConfigurationError`, `configuration_invalid`, `parseConfig`, IDA configuration, or the MCP response budget (14 files, 173 passed) - Built CLI (`providers`, `capabilities`) and `rea mcp` startup, as above This covers the error-message half of the problem. #1183 (doctor and setup accepting a relative `GHIDRA_INSTALL_DIR`) is a separate change. 🤖 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-17 21:09:22 +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#2712
No description provided.