Identify email attachments with stable processing keys

3 November 2026

An overhead view of a person typing on a laptop.
Illustrative photograph. Cropped and resized. Photo: “Woman Working Business” — Kristin Hardwick / NegativeSpace. · CC0 1.0

To prevent duplicate PDF processing without losing business context, construct a composite processing key that binds the receiving mailbox, message identifier, attachment identifier, and target business purpose. Matching file content alone is insufficient; evaluating whether two incoming email deliveries represent redundant work requires checking both payload identity and operational context.

Constructing a composite attachment identity

In automated PDF ingestion pipelines, relying solely on an original filename (such as attachment.pdf) or a raw file checksum creates severe deduplication errors. When a single email message carries two identically named attachments or when separate messages submit identical documents for distinct workflow purposes, evaluating only the file hash can falsely drop valid work or collapse independent tasks.

Keep the mailbox, stable message ID and attachment ID together as a structured tuple. Record the authorised purpose alongside it and scope any reused processing result to that purpose. Preserve filename as a display value. If the implementation hashes several components, encode their boundaries explicitly so different tuples cannot accidentally concatenate to the same text. Intake results

Suppose one email contains two identically named PDFs. Give each attachment its own provider attachment identity under the same mailbox and message. Different file bytes mean distinct payloads. If the bytes and purpose match, a design may reuse the computed result while still retaining both source attachments and their delivery records. If one attachment was submitted for a different purpose, decide eligibility for reuse independently; similarity of wording or filenames is insufficient. This same-message pair is the hypothetical case. The observed controls below used different message contexts. Intake results

By separating the source delivery context (mailbox, message, attachment) from the execution job key (payload SHA-256 plus business purpose), intake systems can distinguish between an exact network re-delivery and a valid re-submission across different cases. Intake results

Worked decision ledger from synthetic intake test

The following scenario illustrates intake deduplication using synthetic test fixtures from a local evaluation environment running Python 3.12.14 and pypdf 6.10.0. The test suite processed 5 delivery records representing 4 unique source contexts and generated 2 distinct processing jobs. Attachment manifest · Intake results

In this exercise, a single standard PDF (synthetic-tables.pdf) with SHA-256 checksum beee40fa0bfd1f3c5819f6fb919a0c3791100856cc1626d3db0f510d60f58905 was delivered across multiple contexts alongside a malformed fixture (cd81e66923e340ef3fb3bb2c8ba97827c56afaf654ea584766f7f119a1286a05). Attachment manifest · Intake results

Delivery IDSource Context (Mailbox / Message / Attachment)Business PurposePayload SHA-256Intake StateAssigned Job Key / Outcome
D01SYN-MB01 / M01 / A01SYN-CASE-Abeee40fa...8905CREATED_JOBJob SYN-J01 (90c4730d...75d7)
D02SYN-MB01 / M01 / A01SYN-CASE-Abeee40fa...8905DUPLICATE_DELIVERYNone (Dropped as redundant intake)
D03SYN-MB01 / M02 / A02SYN-CASE-Abeee40fa...8905REUSED_JOB_NEW_CONTEXTJob SYN-J01 (90c4730d...75d7)
D04SYN-MB01 / M03 / A03SYN-CASE-Bbeee40fa...8905CREATED_JOBJob SYN-J02 (3ccb539f...6d74)
D05SYN-MB01 / M04 / A04SYN-CASE-Acd81e669...6a05QUARANTINED_PARSE_FAILUREPending manual review (PdfReadError)

Intake results · Attachment manifest

Key observations from the decision ledger

  • Exact delivery duplication (D02): Delivery D02 shared the mailbox, message, attachment and purpose of D01 and was recorded as a duplicate delivery.
  • Job reuse across messages (D03): Delivery D03 arrived in message M02 with attachment A02. Because its payload SHA-256 (beee40fa...) and purpose (SYN-CASE-A) matched job SYN-J01, the system logged the new context while reusing the existing parsed job output of 3 pages.
  • Cross-purpose job creation (D04): Delivery D04 carried the exact same PDF binary (beee40fa...) under filename attachment.pdf, but specified business purpose SYN-CASE-B. Because the purpose differed from SYN-CASE-A, the system correctly generated a new processing job (SYN-J02) with key 3ccb539f...6d74.

Intake results · Attachment manifest

Resolving ambiguous and difficult intake edge cases

The most complex outcome in this intake ledger is Delivery D05, which triggered a QUARANTINED_PARSE_FAILURE due to a PdfReadError exception when reading malformed file structure cd81e669...6a05. Attachment manifest · Intake results

Operational escalation for D05

  • Responsible role: Intake Operations Analyst.
  • Required action: Inspect the quarantined file payload to determine whether the document was damaged in transit or requires upstream re-transmission.
  • Closure criteria: Manually resolve the quarantine record by either replacing the payload with a valid stream or flagging the message context as unserviceable.

Technical boundaries and limitations

A match to a trusted file checksum identifies the compared bytes, but it does not confirm intended ownership, current access permissions, or semantic factual correctness. Furthermore, successful parsing during local synthetic tests confirms only structural extraction via pypdf 6.10.0; it does not constitute malware clearance or security validation. In local test executions, live mail API integration and security scanning were explicitly recorded as NOT_RUN.

Intake results · Attachment manifest

Implementation checklist and next step

To deploy stable processing keys across email intake queues, verify the following controls:

  • Bind four-part identity: Ensure ingestion logic records mailbox, message_id, attachment_id, and purpose before deduplication checks.
  • Derive composite job keys: Compute execution job keys using payload SHA-256 combined with the business purpose code.
  • Separate delivery tracking from job execution: Allow multiple distinct delivery contexts to link to a single parsed job output when SHA-256 and purpose match.
  • Isolate malformed payloads: Quarantine parsing exceptions immediately while maintaining message lineage for operational review.

Intake results · Attachment manifest

Next Step: Audit your ingestion pipeline logic to ensure the job key generator includes the target business purpose alongside the file SHA-256 hash before enabling automated intake deduplication.

Part of the Deduplicate PDF email attachments without losing their case guide.

Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with NotebookLM. Source checks and editing by Kairos (Codex).