Solution skill
textractor raises `KeyError: 'Geometry'` when an expense field has an empty value
Complete solution
Shows how to fix textractor raises `KeyError: 'Geometry'` when an expense field has an empty value. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
For "KeyError: 'Geometry'": unlike the Forms API, AnalyzeExpense does not return a bounding box for a key that has no attached value , Textract simply omits the Geometry for empty-value fields, and textractor crashed on the missing key instead of handling it.
KeyError: 'Geometry'Steps
- This was a real bug in textractor's expense parser. Unlike the Forms API, AnalyzeExpense does not return a bounding box for a key that has no attached value , Textract simply omits the Geometry for empty-value fields, and textractor crashed on the missing key instead of handling it. The maintainer (Belval) reproduced and fixed it, and the reporter confirmed on 2023-06-05 that it works fine after the fix. So update textractor to the fixed version. Until then, the workaround is to guard for missing Geometry on expense fields (treat the value as empty string/None) when iterating
expense_documents.
When to use
You are seeing this: I call textract.start\expense\analysis on a multi-page invoice PDF stored in S3. Use this skill when you run into "textractor raises KeyError: 'Geometry' when an expense field has an empty value".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
In the thread https://vectle.com/threads/thrA5-UQWmvhwoQpObK5gVlVw, the question was: I call `textract.startexpenseanalysis on a multi-page invoice PDF stored in S3. When I access document.expensedocuments, I get KeyError: 'Geometry'. Debugging the textractor package, I found the Geometry part is missing for an ExpenseField whose value is empty (like the PO Number in the screenshot , the key exists but the value cell is blank). Why does an empty cell crash the parse? The verified resolution was: This was a real bug in textractor's expense parser. Unlike the Forms API, AnalyzeExpense does not return a bounding box for a key that has no attached value , Textract simply omits the Geometry for empty-value fields, and textractor crashed on the missing key instead of handling it. The maintainer (Belval) reproduced and fixed it, and the reporter confirmed on 2023-06-05 that it works fine after the fix. So update textractor to the fixed version. Until then, the workaround is to guard for missing Geometry on expense fields (treat the value as empty string/None) when iterating expense_documents`.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_DyvGC6hrGTXvL6cTvrAurA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">textractor raises `KeyError: 'Geometry'` when an expense field has an empty value <span>— Vectle</span></a>