Skip to content

feat: api post model embedding processes#514

Closed
irumvanselme wants to merge 3 commits into
mainfrom
feat/api-POST-model-embedding-processes
Closed

feat: api post model embedding processes#514
irumvanselme wants to merge 3 commits into
mainfrom
feat/api-POST-model-embedding-processes

Conversation

@irumvanselme

@irumvanselme irumvanselme commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes

Comment on lines +113 to +123
totalDocuments += await this.pushEntitiesToQueue(modelId, entitySource.entityType, entitySource.findAll());
}

// 5. Update the embedding process state with the total number of documents that were pushed to the queue.
return this.embeddingProcessStateRepository.update(embeddingProcessState.id, {
status: ModelInfoApiSpecs.ModelInfo.EmbeddingProcessStates.Enums.Status.IN_PROGRESS,
totalDocuments,
});
} catch (e) {
throw new Error(`Failed to trigger embedding process for model ${modelId}.`, { cause: e });
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: If pushing tasks to the SQS queue fails, the PENDING EmbeddingProcessState is not cleaned up, blocking all future embedding attempts for that model.
Severity: HIGH

Suggested Fix

In the catch block within the triggerEmbeddingProcess function (around line 121), add logic to delete the EmbeddingProcessState document that was created at the beginning of the process. This ensures that a failed attempt cleans up after itself and doesn't block subsequent runs.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: backend/src/embeddings/embeddingProcess/embeddingProcess.service.ts#L87-L123

Potential issue: The process creates an `IEmbeddingProcessState` document with a
`PENDING` status before pushing tasks to the SQS queue. If any `pushTaskToQueue` call
fails, which can happen due to network issues or SQS errors, the exception is caught but
the state document is not deleted. This orphaned `PENDING` state will cause subsequent
attempts to trigger embeddings for the same model to fail with an
`EmbeddingProcessAlreadyRunningError`. This effectively locks the model from being
re-embedded until the state is manually cleared from the database.

Did we get this right? 👍 / 👎 to inform future reviews.

@irumvanselme
irumvanselme deleted the feat/api-POST-model-embedding-processes branch July 14, 2026 07:36
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.

1 participant