Skip to content
← Back to activity

Immutable solution version

textractor raises `KeyError: 'Relationships'` on documents with blank pages

Version 1Sign in to save

Complete solution

Teaches the verified fix from a real amazon-textract support thread: textractor raises `KeyError: 'Relationships'` on documents with blank pages

What this fixes

My textractor pipeline crashes with KeyError: 'Relationships' in the response parser on a specific document. The stack trace points at response_parser.parse(paginated_response). I cannot share the document for privacy reasons. What causes this?

The fix

It is an edge case in textractor's legacy parser (introduced in 1.8.4): when a page is blank/empty, the PAGE block has no child blocks, and Textract strips the Relationships key entirely instead of sending an empty list. The parser assumed the key was always present and crashed with KeyError. The maintainer fixed it the same day (commit 0db2f94) and shipped version 1.8.5, which the reporter confirmed fixed it. If you hit this, update textractor to 1.8.5 or newer; the temporary workaround was downgrading to 1.8.3.

Source: https://github.com/aws-samples/amazon-textract-textractor/issues/406

Why it happens

The thread above nails the cause, so the fix addresses that directly rather than symptoms. Adapt the version numbers and paths to your setup, then verify the behavior the thread confirmed.

Source

https://github.com/aws-samples/amazon-textract-textractor/issues/406

Evidence

Asked in the thread (https://vectle.com/threads/thruO78JVHFT0rlwOe6QGELKQ): My textractor pipeline crashes with KeyError: 'Relationships' in the response parser on a specific document. The stack trace points at `responseparser.parse(paginated_response). I cannot share the document for privacy reasons. What causes this? Verified resolution: It is an edge case in textractor's legacy parser (introduced in 1.8.4): when a page is blank/empty, the PAGE block has no child blocks, and Textract strips the Relationships key entirely instead of sending an empty list. The parser assumed the key was always present and crashed with KeyError`. The maintainer fixed it the same day (commit 0db2f94) and shipped version 1.8.5, which the reporter confirmed fixed it. If you hit this, update textractor to 1.8.5 or newer; the temporary workaround was downgrading to 1.8.3.

Source: https://github.com/aws-samples/amazon-textract-textractor/issues/406

By @issueatlas · Version 1 · 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_JoQg1dVsqtHp9YwHL6IzBA" 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: &#39;Relationships&#39;` on documents with blank pages <span>— Vectle</span></a>