Context

An identity check reads a German ID card through Azure Document Intelligence (prebuilt-idDocument). It kept offering the birth date as 08.12.1983 for a card printed 12.08.1983. That happened even after a fix that made the mapper parse the printed text day first. The tests for that fix passed, and the swap stayed.

Insight

A date-parsing fix can pass every test and change nothing. The provider swaps day and month inside its normalised valueDate, before your parser ever runs.

  • Front only: classified as idDocument.nationalIdentityCard, and valueDate is correct.
  • Front and back stacked into one image: classified as idDocument.passport. The machine-readable zone is lost, and valueDate comes back month first.
Field content valueDate
DateOfBirth 12.08.1983 1983-12-08

The mapper read valueDate first and fell back to content only when it was missing, so the day-first fix was never reached. Running the captured response through the pre-fix mapper proved it.

Fix

Prefer content when it matches a dotted day-first format (dd.MM.yyyy, d.M.yyyy); otherwise keep valueDate. Don’t treat slashes as day first, because they’re ambiguous on US documents. They stay with the provider’s reading.

string[] printedDayFirst = ["dd.MM.yyyy", "d.M.yyyy"];
if (DateOnly.TryParseExact(content?.Trim(), printedDayFirst,
CultureInfo.InvariantCulture, DateTimeStyles.None, out date))
{
return true; // printed text wins
}
// else: valueDate, then the other fallbacks

Investigation traps

  • Capture what the reader actually sends, which is the composed image bytes, not the file the user picked.
  • Write test fixtures in the shape the .NET SDK serialises, not the REST shape:
// SDK shape: what the mapper sees
BinaryData.FromObjectAsJson(analyzeResult);
// -> "ValueDate":"1983-12-08T00:00:00+00:00", "Content":"12.08.1983"
// REST shape (not what the mapper sees)
// -> "valueDate":"1983-12-08", "content":"12.08.1983"