Skip to content

fix: let exceptions bubble up from getAllManagedIndices() instead of silently returning empty#442

Closed
kingjia90 with Copilot wants to merge 5 commits into
2026.xfrom
copilot/fix-review-comment-391
Closed

fix: let exceptions bubble up from getAllManagedIndices() instead of silently returning empty#442
kingjia90 with Copilot wants to merge 5 commits into
2026.xfrom
copilot/fix-review-comment-391

Conversation

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

getAllManagedIndices() was swallowing all exceptions from getStats() and returning [], causing the cleanup command to silently report "No unused indices found" on connection/auth failures — masking real operational problems.

Changes

  • UnusedIndexCleanupService::getAllManagedIndices() — removed the catch (Exception) block; exceptions from SearchIndexServiceInterface::getStats() now propagate up to CleanupUnusedIndicesCommand::execute(), which already handles them by writing the error message to output
  • doc/02_Configuration/03_Index_Management.md — resolved merge conflict, keeping improved wording from base branch while retaining the Cleanup Unused Indices section introduced by the PR
// Before: silently hides failures
try {
    $stats = $this->searchIndexService->getStats($indexPrefix . '*');
} catch (Exception) {
    return [];  // ← masks connection errors, auth failures, etc.
}

// After: exception propagates to command for proper error reporting
$stats = $this->searchIndexService->getStats($indexPrefix . '*');

cancan101 and others added 3 commits February 7, 2026 20:30
- add generic-data-index:cleanup:unused-indices command
- default behavior deletes unmanaged stale -odd/-even indices not referenced by aliases
- add --dry-run option to preview deletions without changes
- implement UnusedIndexCleanupService to detect candidates via prefix + alias diff
- add unit tests for selection, dry-run, and execute behavior
- document new cleanup command in index management docs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix the code for review comment in PR #391 fix: let exceptions bubble up from getAllManagedIndices() instead of silently returning empty Jun 23, 2026
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 New Major Issues (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot AI requested a review from kingjia90 June 23, 2026 11:09
@kingjia90 kingjia90 closed this Jun 24, 2026
@kingjia90 kingjia90 deleted the copilot/fix-review-comment-391 branch June 24, 2026 08:31
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants