From 983fb5bd6790ea2c20d7ae82d3d09364beeedad9 Mon Sep 17 00:00:00 2001 From: Peter Foster Date: Thu, 22 Jan 2026 19:49:10 +0000 Subject: [PATCH] fix: Fail CV checks that return no extractable data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CVs that parse with no employment, no education, and unknown name are likely scanned images or corrupted files. Instead of completing with score 100 (misleading), fail with a clear error message. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/RealCV.Infrastructure/Jobs/ProcessCVCheckJob.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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";