Skip to content

fix(ghidra): report a missing existing-project program as a configuration error - #8222

Merged
morluto merged 2 commits into
morluto:mainfrom
macjayz:fix/ghidra-missing-project-program
Oct 31, 2026
Merged

morluto merged 2 commits into
morluto:mainfrom
macjayz:fix/ghidra-missing-project-program

Conversation

@macjayz

@macjayz macjayz commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #8216. When REA_GHIDRA_PROJECT_PATH selects a project with no root program of the selected name, the first provider query now returns configuration_invalid for REA_GHIDRA_PROGRAM_NAME instead of generic execution_failure with rea doctor advice.

Problem and expected behavior

  • Trigger: existing-project mode, with the program name (from REA_GHIDRA_PROGRAM_NAME or, when unset, the target basename) not naming a root program in the project. Ghidra's headless analyzer aborts with Requested project program file(s) not found: <name> (thrown by HeadlessAnalyzer.processNoImport when -process matched nothing).
  • Before: projectPrimarySessionError fell through to ProviderAdapterError, so the caller saw Analysis could not complete. Run rea doctor.... The actual reason was only in captured launcher output, and a target-free doctor run reports healthy.
  • After: a ConfigurationError with setting REA_GHIDRA_PROGRAM_NAME. The message names the program and whether it was configured or defaulted from the target file name. The remediation says to set the exact root program name in the environment that starts REA, then restart and reopen. The project selection is preserved, no fresh-import fallback is attempted, and the original GhidraSessionError and diagnostics stay attached as the cause.

Change and scope

  • GhidraProviderClient.ts: readGhidraFailureOutput also exposes the operation-scoped stdout/stderr text. If it contains Ghidra's refusal for the exact program name REA passed to -process, the projection returns the new error. The match requires the name to end at end-of-line or a space, so a longer name such as fixture_other or unrelated output does not match.
  • The resolved program_name from the committed existing-project profile now reaches the projection. Limits and program name travel together as one GhidraProjection argument, keeping config's live getters for runtime-updated limits.
  • The check runs after the existing JVM memory projection and before the exit-signal and generic fallbacks.

Not included: #8217 (changed-project refusal), any doctor check that lists project programs, and any change to program-name validation, project copying or selection.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: projectPrimarySessionError in GhidraProviderClient.ts, consuming the launcher's operation-scoped failure_output. No producer changes.
  • Contribution scope fit and linked maintainer decision: not applicable. Error projection within existing boundaries.
  • CLI and MCP/tool-catalog contract: for this case only, code changes from execution_failure to configuration_invalid, with details.settings naming REA_GHIDRA_PROGRAM_NAME, plus new message and remediation.action text. Other failures are unchanged.
  • Provider, bridge, target-format, or platform compatibility: Ghidra existing-project mode only. Launcher, bridge and fresh-import mode are unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): project and program selection are unchanged and still fail closed. Cleanup composition through projectSessionError is unchanged.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): none.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • 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: src/ghidra/GhidraProvider.behavior.test.ts, new "Ghidra missing project program" block, using a temporary .gpr/.rep and an injected start failure carrying Ghidra's abort line:
    • defaulted name (fixture, the target basename): configuration_invalid, REA_GHIDRA_PROGRAM_NAME setting, "defaulted from the target file name" origin, no rea doctor in the remediation
    • explicit REA_GHIDRA_PROGRAM_NAME=program_gamma: "set by REA_GHIDRA_PROGRAM_NAME" origin
    • Ghidra naming a different program (fixture_other): stays execution_failure
    • unrelated launch output: stays execution_failure
  • Base reproduction or other evidence: executed. With only GhidraProviderClient.ts reverted to d48e472fa, the first two tests fail and the two controls pass. The abort text is source-derived from Ghidra 12.1.4 HeadlessAnalyzer.java and matches the output quoted in [Bug] Missing Ghidra project program is hidden behind generic doctor advice #8216.
  • User-visible CLI/MCP output (if applicable), defaulted name from the test:
    • code: configuration_invalid
    • message: REA configuration is invalid: Ghidra found no root program named "fixture" (defaulted from the target file name because REA_GHIDRA_PROGRAM_NAME is unset) in the selected REA_GHIDRA_PROJECT_PATH project.
    • remediation: Set REA_GHIDRA_PROGRAM_NAME to the exact name of a root program in the selected project, in the environment that starts REA (your shell or the MCP client's registration), then restart REA and open the target again. REA did not modify the project or fall back to a fresh import.
  • Remaining proof gaps: no live Ghidra run, since Ghidra is not installed on the machine used. The tests inject the launcher failure. If Ghidra's output for this abort were truncated out of the operation-scoped capture, the previous generic result would still apply. The full npm run check:pr and docs:check were not run locally.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

Not a boundary or lifecycle change: only the projection of an existing startup failure changes.

Validation performed

  • npx vitest run src/ghidra/GhidraProvider.behavior.test.ts -t "Ghidra missing project program": 4 passed. With the source change reverted, 2 failed and 2 passed.
  • npx vitest run src/ghidra: 34 files, 984 tests passed.
  • npx tsc --noEmit -p .: no errors.
  • npm run lint: passed, module boundaries checked in 3446 files. The oxlint warnings on GhidraProviderClient.ts match main.
  • npx oxfmt --check on both changed files: correct format.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Callers that branched on execution_failure for this case now get configuration_invalid, which is the code already used for an invalid REA_GHIDRA_PROGRAM_NAME.
  • Real Hopper/Ghidra, browser, or OS coverage: none; unit-level only (macOS arm64, Node 26.12.1).
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: not applicable. The match reads REA's already captured, redacted launcher output and requires the exact configured or defaulted name.

Author readiness

Human owner: @macjayz

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

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.

…tion error

When REA_GHIDRA_PROJECT_PATH selects a project that has no root program
with the selected name, Ghidra's headless analyzer aborts with
"Requested project program file(s) not found: <name>". REA reported this
as a generic execution_failure with rea doctor advice, and the reason was
visible only in the captured diagnostics.

Recognize that refusal in the operation-scoped launcher output, matching
only the exact name REA passed to -process, and return a
ConfigurationError for REA_GHIDRA_PROGRAM_NAME. The message says whether
the name was configured or defaulted from the target file name, and the
remediation explains how to select the exact root program. The selected
project is unchanged and there is no fallback to a fresh import. Other
launch failures keep their existing projection.

Fixes morluto#8216
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with the previous test-brittleness finding fixed and no new blocking issues found.

Summary

The PR reports a missing program in an existing Ghidra project as configuration_invalid, naming REA_GHIDRA_PROGRAM_NAME.

  • A missing Ghidra project program points to the program-name setting.

Reviews (2) · Last reviewed commit: "test(ghidra): assert missing-program gui..." · Reviewed by Greptile

@macjayz
macjayz marked this pull request as ready for review October 30, 2026 22:08
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-30T22:08:25.872616Z
We couldn’t complete this review. Comment @codex review to try again.
3851a4e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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.

Compare the projected setting constraint and remediation with
ghidraMissingProgramGuidance instead of freezing explanatory phrases,
following docs/testing.md. The program name and configured-or-defaulted
origin are still checked independently.
@morluto
morluto merged commit 1dc97d8 into morluto:main Oct 31, 2026
44 checks passed
@morluto morluto added area: domain Domain logic, errors, and pure functions bug Something isn't working provider: ghidra Analysis provider / engine: ghidra labels Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working provider: ghidra Analysis provider / engine: ghidra

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Missing Ghidra project program is hidden behind generic doctor advice

2 participants