fix(cv-import): bound source retention and guard worker recovery

This commit is contained in:
cesnimda
2026-10-26 14:41:53 +01:00
parent e8f76a9dea
commit 9e1726c61d
14 changed files with 115 additions and 9 deletions
@@ -514,6 +514,11 @@ public sealed partial class ProfileCvController : ControllerBase
}
catch (OperationCanceledException)
{
if (run.ParserVersion == DocumentParserVersion && operationContext is not null)
{
_db.Entry(run).State = EntityState.Detached;
throw;
}
run.Status = "queued";
run.ErrorMessage = "CV processing was interrupted before completion.";
run.CompletedAtUtc = null;
@@ -522,6 +527,12 @@ public sealed partial class ProfileCvController : ControllerBase
}
catch (Exception ex)
{
if (run.ParserVersion == DocumentParserVersion && operationContext is not null &&
!await _db.UserOperations.AsNoTracking().AnyAsync(o => o.Id == operationContext.Lease.OperationId && o.LeaseToken == operationContext.Lease.LeaseToken && o.Status == OperationStatuses.Running && o.CancellationRequestedAtUtc == null && o.LeaseExpiresAtUtc > DateTime.UtcNow, CancellationToken.None))
{
_db.Entry(run).State = EntityState.Detached;
throw new OperationCanceledException("The import worker lease is no longer active.");
}
var generationFailure = ex as AiGenerationException;
var retryable = generationFailure?.Retryable == true;
var failureMessage = generationFailure?.Message