diff --git a/src/RealCV.Infrastructure/Jobs/ProcessCVCheckJob.cs b/src/RealCV.Infrastructure/Jobs/ProcessCVCheckJob.cs index 3d206b6..7eebb60 100644 --- a/src/RealCV.Infrastructure/Jobs/ProcessCVCheckJob.cs +++ b/src/RealCV.Infrastructure/Jobs/ProcessCVCheckJob.cs @@ -92,6 +92,19 @@ public sealed class ProcessCVCheckJob "Parsed CV for check {CheckId}: {EmploymentCount} employment entries", cvCheckId, cvData.Employment.Count); + // Validate that the CV contains meaningful data + // A CV with no name, no employment AND no education is likely a parsing failure + if (cvData.Employment.Count == 0 && cvData.Education.Count == 0 && + (string.IsNullOrWhiteSpace(cvData.FullName) || cvData.FullName == "Unknown")) + { + _logger.LogWarning( + "CV check {CheckId} parsed with no extractable data - possible scanned/image PDF or parsing failure", + cvCheckId); + throw new InvalidOperationException( + "Could not extract any employment or education data from this CV. " + + "The file may be a scanned image, password-protected, or in an unsupported format."); + } + // Step 4: Save extracted data cvCheck.ExtractedDataJson = JsonSerializer.Serialize(cvData, JsonDefaults.CamelCaseIndented); cvCheck.ProcessingStage = "Verifying Employment";