Skip to content

fix: keep contacts from succeeded sources when an extractor fails [CM-1341] - #4362

Merged
mbani01 merged 1 commit into
mainfrom
fix/store_partial_successful_security_contacts
Jul 20, 2026
Merged

fix: keep contacts from succeeded sources when an extractor fails [CM-1341]#4362
mbani01 merged 1 commit into
mainfrom
fix/store_partial_successful_security_contacts

Conversation

@mbani01

@mbani01 mbani01 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the reliability of security contact extraction by introducing a new 'partial' status for repositories where some extractors fail but others succeed. The changes ensure that existing contact data is only updated (not deleted) when extraction is partial, preventing accidental data loss. Logging and batch processing are also updated to reflect this new status and handle partial results safely.

Handling partial extraction results:

  • Added a 'partial' status to ProcessRepoResult and updated return logic in processRepo to use it when some, but not all, extractors fail. [1] [2] [3]
  • Updated ingestSecurityContactsForPurl to call writeContacts with a merge option when the result is 'partial', ensuring existing contacts are not deleted. [1] [2]

Safe database updates:

  • Modified writeContacts and writeContactsChunk to skip soft-deleting contacts for partial results, so only new/updated contacts are merged and no data is lost if an extractor fails. [1] [2]

Batch processing and logging improvements:

  • Updated batch processing and logging to track and report the number of partial results, and to ensure only fully successful or partial results are written. [1] [2] [3]

These changes make the security contact extraction process more robust to partial failures and reduce the risk of losing valid contact data.

Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
@mbani01 mbani01 self-assigned this Jul 20, 2026
Copilot AI review requested due to automatic review settings July 20, 2026 09:58
@cursor

cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how security_contacts rows are deleted and refreshed during failed extractions; stale contacts may linger until a full-success sweep, but the tradeoff reduces contact loss in production data.

Overview
Security contact extraction no longer drops all writes when a single extractor fails. processRepo now aggregates contacts from successful extractors, returns partial when any extractor rejected (and extractor-failed only when every extractor failed), and logs per-extractor failures.

Persistence avoids accidental data loss on partial runs. writeContacts / batch writeContactsChunk skip the pre-upsert soft-delete when status is partial (merge mode), so contacts from sources that weren’t re-evaluated stay active; full refresh still happens on a fully successful pass. On-demand ingest uses the same merge flag for partial results.

Batch logging now reports partial counts separately from ok and failed.

Reviewed by Cursor Bugbot for commit 4ba94fb. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4ba94fb. Configure here.

'UPDATE security_contacts SET deleted_at = NOW(), updated_at = NOW() WHERE repo_id = $(repoId) AND deleted_at IS NULL',
{ repoId },
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

PVR veto leaves stale github-pvr

Medium Severity

On partial runs, merge mode skips soft-deleting existing security_contacts, but processRepo still drops github-pvr rows from the upsert when PVR reports disabled and updates pvr_enabled on the repo. Previously active github-pvr contacts can remain visible while the repo is marked PVR-disabled.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4ba94fb. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds partial extraction handling so successful security-contact sources remain usable when another extractor fails.

Changes:

  • Introduces the partial processing status.
  • Uses merge-only persistence for partial results.
  • Tracks partial outcomes in batch logging.

Metadata: Rename the title to fix: keep contacts from succeeded sources when an extractor fails (CM-1341) to match repository conventions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
processBatch.ts Classifies and logs partial extraction results.
types.ts Adds the partial result variant.
writeContacts.ts Preserves existing contacts during partial writes.
ingestSingle.ts Enables merge-only writes for partial results.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{ repoId: target.repoId, errMsg: failed.reason?.message },
'Extractor failed — preserving existing data',
{ repoId: target.repoId, extractor: EXTRACTORS[i].name, errMsg: r.reason?.message },
'Extractor failed — keeping contacts from remaining sources',
@mbani01
mbani01 merged commit a14dea4 into main Jul 20, 2026
16 checks passed
@mbani01
mbani01 deleted the fix/store_partial_successful_security_contacts branch July 20, 2026 10:17
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.

3 participants