Skip to content

fix(installer): failed index build no longer reports install success (#351)#365

Merged
HumanBean17 merged 2 commits into
masterfrom
fix/installer-exit-code
Jul 4, 2026
Merged

fix(installer): failed index build no longer reports install success (#351)#365
HumanBean17 merged 2 commits into
masterfrom
fix/installer-exit-code

Conversation

@HumanBean17

Copy link
Copy Markdown
Owner

What

java-codebase-rag install returned exit 0 and reported success even when the indexing step (cocoindex / graph build) failed. The cocoindex failure was swallowed and install looked healthy to CI/automation.

Note on the issue's repro

Issue #351 cited two red tests (test_install_emits_indexing_progress_on_stderr, test_install_indexing_exception_renders_failed_footer). Both already pass on current master — the progress/footer machinery they exercise was added after the issue was filed. But the core bug remains in the code: run_install still discards run_init_if_needed(...) and unconditionally return 0 (installer.py). The untested path is a non-exception failure — cocoindex returns returncode != 0 (no raise) → run_init_if_needed returns False → discarded → exit 0.

Fix

run_init_if_needed's False conflated two outcomes: "ran and failed" and "skipped because the index already exists". A naive return 0 if init_ok else 1 (the issue's literal suggestion) would make idempotent re-runs (existing index) wrongly exit 1. So:

  • run_init_if_needed now returns True (ran OK), False (ran and failed), or None (skipped — index exists). It has exactly one caller (run_install).
  • run_install captures the outcome and returns 1 only when it is False; a skip (None) or success (True) stays 0 — mirroring run_update's if not index_ok: return 1.

Test

New test_install_indexing_failure_returns_nonzero patches run_cocoindex_update to return returncode=1 (non-exception failure) and asserts run_install exits 1 with CocoIndex update failed on stderr. TDD: red first (exit 0 despite cocoindex failure), then green.

.venv/bin/python -m pytest tests/test_installer.py -q
# 84 passed

Notes

  • No re-index, env-var, or ontology_version change — installer lifecycle only.
  • Behavior change: install now exits non-zero (1) when indexing fails. Idempotent re-runs over an existing index still exit 0.

Closes #351.

🤖 Generated with Claude Code

HumanBean17 and others added 2 commits July 3, 2026 23:16
…351)

run_install discarded run_init_if_needed's return value and unconditionally
returned 0, so a cocoindex/graph non-zero exit reported a successful install
while the most important step failed silently. Distinguish failure from skip:
run_init_if_needed now returns None when the index already exists (skip) and
False only when indexing ran and failed; run_install returns 1 on that failure,
mirroring run_update's `if not index_ok: return 1` check.

Co-Authored-By: Claude <noreply@anthropic.com>
- Add test_install_over_existing_index_skips_init_and_exits_zero: a re-run
  of install over an existing index skips init and exits 0. Guards the None
  branch of run_init_if_needed (the PR's central design: `if init_outcome is
  False`), so a future `if not init_outcome` simplification that collapses
  None into the failure branch would fail this test instead of silently
  breaking idempotent re-runs. Verified red->green.
- Document at the partial-failure classifier that issue #351's "treat
  skill/agent deploy failures as critical" is intentionally deferred: only
  MCP config failures are critical (a broken MCP config is fatal; missing
  skill/agent hints are recoverable), so the deferred scope reads as a
  deliberate product decision rather than an oversight.

Co-Authored-By: Claude <noreply@anthropic.com>
@HumanBean17

Copy link
Copy Markdown
Owner Author

Addressed 2 review findings:

  1. Skip→None→exit-0 untested — added test_install_over_existing_index_skips_init_and_exits_zero: a re-run over an existing index skips init and exits 0. Guards the PR's central if init_outcome is False design so a future if not init_outcome simplification (collapsing None into the failure branch) fails this test. Verified red→green.
  2. install reports success (exit 0) on failed index build; swallows cocoindex exception #351 deferred scope — documented at the partial-failure classifier that "treat skill/agent deploy failures as critical" is intentionally deferred (only MCP-config failures are critical: fatal vs. recoverable), so it reads as a deliberate decision, not an oversight.

@HumanBean17 HumanBean17 merged commit 9ea38f6 into master Jul 4, 2026
1 check passed
@HumanBean17 HumanBean17 deleted the fix/installer-exit-code branch July 4, 2026 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install reports success (exit 0) on failed index build; swallows cocoindex exception

1 participant