Handle partial failure in a batch PDF request

3 November 2026

A person holds a handheld instrument beside a rack of wired equipment.
Illustrative photograph. Cropped and resized. Photo by Valentin Lacoste on Unsplash. · Unsplash License

When a batch PDF processing request encounters an unreadable file alongside valid documents, first confirm that the batch contract permits independent item outcomes; if it does, isolate the failure at the item level. Completed items receive a SUCCEEDED status with recorded output metadata, and the failed item carries a reason that distinguishes an invalid source from a temporary error. A safe retry mechanism allows clients to rectify and resubmit the failed item without re-running completed files.

Designing an item-level response structure

In bulk PDF processing, batch requests must handle mixed item outcomes. If an entire batch fails due to a single corrupted input, valid documents are delayed and processing resources are wasted on repeated parsing. A resilient batch API avoids all-or-nothing failures by applying an independent item contract where each file follows its own execution lifecycle.

To illustrate this architecture, consider a hypothetical request involving a proposed four-item batch containing three valid PDF documents and one unreadable file. Ask the service to return a structured item-level response. The local comparison did not expose an HTTP API.

This model is defined in the first-party synthetic contract batch-contract.json under the parameter "atomicity": "INDEPENDENT_ITEMS". In the corresponding execution record batch-results.json—evaluated using Python 3.12.14 and pypdf 6.10.0 with zero external network calls —each document is tracked independently. In this local test fixture, HTTP API integration, authentication, and durability across restarts were explicitly marked as NOT_TESTED or NOT_IMPLEMENTED, and operations were restricted to page-count extraction rather than file conversion or optical character recognition (OCR). Batch contract · Batch results

Under this structure, valid files (SYN-I01, SYN-I02, and SYN-I07) succeed, generating outputs that record the extracted page count and a source_sha256 checksum (e.g. beee40fa0bfd1f3c5819f6fb919a0c3791100856cc1626d3db0f510d60f58905). Matching a recorded file checksum verifies that the processed file matches the uploaded payload; it does not establish document ownership, permissions, or factual correctness. Conversely, when the parser encounters an unreadable file (SYN-I04), it logs a PARSE_FAILURE caused by a PdfReadError exception and assigns a state of FAILED_PERMANENT. Batch results

Worked decision ledger and exception record

Managing partial failures requires a decision ledger that categorises item states, assigns operational responsibility, and defines resolution criteria.

The four rows below use a subset of the eight local results to illustrate the proposed four-item scenario. They were not measured in a separate four-item API request. The source is batch-results.json: Batch results

Item IDFixture TypeRecorded EventState ClassificationAttempt CountResponsible PartyResolution Criterion
SYN-I01Valid PDFPAGE_COUNT_SAVEDSUCCEEDED1API EngineOutput stored; reused on retries.
SYN-I02Valid PDFPAGE_COUNT_SAVEDSUCCEEDED1API EngineOutput stored; reused on retries.
SYN-I07Valid PDFPAGE_COUNT_SAVEDSUCCEEDED1API EngineOutput stored; reused on retries.
SYN-I04Malformed PDFPARSE_FAILURE (PdfReadError)FAILED_PERMANENT1Client OperationsReplace corrupt payload with valid PDF; resubmit item.

Batch results

These illustrative rows show three saved page counts and one parse failure. An unreadable input in a real job may have another cause; classify it from the observed error and the contract. Across the broader eight-item reference dataset in batch-results.json, initial counts recorded 4 succeeded, 1 retryable failure, 1 permanent failure, 1 cancelled, and 1 queued item. Following a retry pass for the transient error, final counts reached 5 succeeded, 1 permanent failure (SYN-I04), 1 cancelled, and 1 queued item. Batch results

Safe retry strategy without re-executing valid items

Once an item-level response isolates a permanent failure, decide first whether another attempt is justified. Re-running the full batch without filtering completed items creates duplicate processing overhead.

A safe retry strategy relies on three principles:

  1. Status filtering: The client inspects the response manifest and targets only items marked as FAILED_RETRYABLE. A replacement for a permanently failed input should be submitted as a new version linked to the failed item.
  2. Result reuse: When a retry request is submitted, the API engine identifies completed items (SYN-I01, SYN-I02, SYN-I07) and logs a REUSED_SUCCESS event, returning existing metadata without re-parsing the PDF binary.
  3. Payload replacement: For structural errors like SYN-I04 (PdfReadError), resubmitting the identical byte stream reproduces the failure. The content owner must replace the input fixture with a valid PDF file before triggering a retry. Batch results

If the replacement changes the input bytes or instructions, record its new identity and use the request key authorised for that changed work. Retain the original failed version and the three successful items. Verify that the receiving workflow reads the replacement result without replaying the whole batch. Batch contract · Batch results

Compact acceptance checklist and next steps

When evaluating a PDF batch processing API for partial failure handling, verify these operational requirements:

  • Independent item atomicity: Confirm the API contract explicitly supports per-item processing (INDEPENDENT_ITEMS) rather than all-or-nothing transactions.
  • Granular state classification: Verify that the API distinguishes transient errors (FAILED_RETRYABLE) from structural syntax errors (FAILED_PERMANENT).
  • Exception logging: Ensure unreadable files capture specific parsing exceptions (e.g. PdfReadError) in the item manifest.
  • Execution reuse: Test that retried batch calls log REUSED_SUCCESS for completed items rather than re-executing document transformations.
  • Integrity auditing: Confirm output manifests record source-file checksums (source_sha256) for input verification; use a separate output identity where the operation produces a file.

Batch contract · Batch results

Next step

Run a staging test with a four-item batch containing three valid PDFs and one deliberately corrupted byte sequence to confirm that your client integration parses the per-item status response and skips re-execution for completed files.

Part of the Reconcile partial failures in a batch PDF job guide.

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