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

Every configuration failure projected the same message, "REA configuration
is invalid. Run `rea doctor` and fix the reported setting.", with no
details. The environment parser discarded the issue that names the variable
(for example `REA_GHIDRA_NATIVEAOT_JAR must be absolute`), and doctor can
report healthy for that environment, so neither the CLI, the MCP startup
message, nor doctor told callers which setting to correct.

ConfigurationError now carries the rejected settings and their constraints
(never their values). The projection names them in its message, lists them
in `details.settings`, and asks the caller to correct those settings where
REA is started. Errors without a named setting keep the previous message.

Fixes #1184

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-09 04:08:43 +00:00
co-authored by Claude Opus 5.5
parent e6abaefbbc
commit 0a0244db42
9 changed files with 145 additions and 14 deletions
+15 -5
View File
@@ -50,7 +50,7 @@ export const readIdaConfiguration = (
try {
if (statSync(path).size > 65_536)
return err(
new ConfigurationError(
idaConfigurationError(
"REA_IDA_MCP_CONFIG exceeds the 64 KiB registration size.",
),
);
@@ -64,17 +64,27 @@ export const readIdaConfiguration = (
return parsed.success
? ok(parsed.data)
: err(
new ConfigurationError(
idaConfigurationError(
"REA_IDA_MCP_CONFIG must contain an IDA MCP command/args or local url registration; see docs/ida-provider.md.",
{ cause: parsed.error },
parsed.error,
),
);
} catch (cause: unknown) {
return err(
new ConfigurationError(
idaConfigurationError(
`Cannot read IDA MCP registration ${path}; provide a readable JSON configuration.`,
{ cause },
cause,
),
);
}
};
/** A REA_IDA_MCP_CONFIG rejection that names the setting it concerns. */
export const idaConfigurationError = (
constraint: string,
cause?: unknown,
): ConfigurationError =>
new ConfigurationError(constraint, {
...(cause === undefined ? {} : { cause }),
settings: [{ setting: "REA_IDA_MCP_CONFIG", constraint }],
});
+3 -2
View File
@@ -11,13 +11,14 @@ import type {
ProviderTargetSupport,
} from "../application/AnalysisProvider.js";
import type { AppConfig } from "../config.js";
import { ConfigurationError } from "../domain/configurationErrors.js";
import type { ConfigurationError } from "../domain/configurationErrors.js";
import { createHash } from "node:crypto";
import canonicalize from "canonicalize";
import type { Result } from "../domain/result.js";
import {
readIdaConfiguration,
type IdaConfiguration,
idaConfigurationError,
} from "./IdaConfiguration.js";
import {
createIdaMcpConnection,
@@ -165,7 +166,7 @@ export class IdaProvider implements AnalysisProviderCandidate {
const readIdaConfigurationNotConfigured = () =>
err(
new ConfigurationError(
idaConfigurationError(
"Set REA_IDA_MCP_CONFIG to an upstream IDA MCP JSON registration; see docs/ida-provider.md.",
),
);