Skip to content

fix(dir/server): handle missing manifest gracefully to prevent orphaned search index rows - #2067

Merged
paralta merged 1 commit into
agntcy:mainfrom
vijit-vishnoi:fix/issue-2066-orphan-index
Aug 25, 2026
Merged

paralta merged 1 commit into
agntcy:mainfrom
vijit-vishnoi:fix/issue-2066-orphan-index

Conversation

@vijit-vishnoi

Copy link
Copy Markdown
Contributor

Fixes #2066

Problem Statement

Previously, StoreService.Delete would fail and return an error if a record's manifest was already missing from the OCI store. Because the OCI deletion step failed, the subsequent database search-index cleanup step was never reached, leaving behind an orphaned, unrecoverable row in the search index.

Proposed Changes

This PR implements the maintainer's proposed solution to make "record not found in OCI" a non-fatal outcome, allowing the deletion process to continue and clean up the database index:

  1. OCI Store (server/store/oci/internal.go):
    • Updated deleteFromOCIStore and deleteFromRemoteRepository to check for errdef.ErrNotFound using errors.Is.
    • If the manifest is missing, it logs an informational message and returns nil (success), treating the deletion as idempotent.
  2. Controller (server/controller/store.go):
    • Updated the error evaluation block immediately following s.store.Delete.
    • The deletion process now proceeds to s.db.RemoveRecord even if the store returns a codes.NotFound gRPC status.
  3. Unit Tests Added:
    • TestDeleteFromOCIStore_NotFound: Verifies that attempting to delete a non-existent CID in the OCI store correctly returns nil.
    • TestStoreDelete_NotFound: Verifies that the controller's Delete method correctly invokes the database RemoveRecord mock even when the OCI store returns codes.NotFound.

Checklist

  • I have read the contributing guidelines
  • I have signed off my commits (DCO)
  • I have added tests that prove my fix is effective
  • All local tests pass successfully (go test)

@vijit-vishnoi
vijit-vishnoi requested a review from a team as a code owner August 25, 2026 12:11
@github-actions github-actions Bot added the size/S Denotes a PR that changes 50-199 lines label Aug 25, 2026
@vijit-vishnoi vijit-vishnoi changed the title fix: handle missing manifest gracefully to prevent orphaned search index rows fix(dir/server): handle missing manifest gracefully to prevent orphaned search index rows Aug 25, 2026
@paralta

paralta commented Aug 25, 2026

Copy link
Copy Markdown
Member

@vijit-vishnoi Please run FIX=true task lint to fix the linter failures

@vijit-vishnoi
vijit-vishnoi force-pushed the fix/issue-2066-orphan-index branch from 6987e4e to cea68c5 Compare August 25, 2026 14:05
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@paralta paralta left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 Thank you so much for picking this issue up and for how quickly you turned it around — neat fix!

@paralta
paralta merged commit 9aa4eb2 into agntcy:main Aug 25, 2026
32 checks passed
@vijit-vishnoi
vijit-vishnoi deleted the fix/issue-2066-orphan-index branch August 25, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 50-199 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Deleting a record can orphan its search-index row, permanently and unrecoverably

2 participants