Reconcile partial failures in a batch PDF job
25 August 2026
A single batch status can hide a failed input, a cancelled item or work that has never started. This local exercise begins with eight jobs and retries one recoverable failure. Five finish successfully, while the permanent failure, cancellation and queued item stay visible. The record shows how to reconcile each input to its own outcome.
Related articles
- Use idempotency keys in a PDF processing API
- Handle partial failure in a batch PDF request
- Return an output manifest for a PDF batch
- Handle expired result links in a PDF API
What does success mean for one item in the batch?
Consider an organisation submitting eight PDFs for a bounded operation. Some finish, one is unreadable, another encounters a temporary failure, and a user cancels a queued item. The service must preserve those differences. A single batch-level label such as “failed” gives the operator too little information to recover safely.
Choose the unit of work before designing requests. If each file can be processed independently, retain successful outputs and retry only eligible failures. If the business needs one complete bundle, separate processing from release: the service may finish individual files, while a publication gate withholds the bundle until its acceptance conditions are met. That is different from assuming all writes form one transaction.
Where this guidance stops
The contract below is proposed and vendor-neutral. It does not establish an ArkePDF API, authentication service or deployment. The local example extracts page counts from synthetic PDFs; it does not benchmark conversion, OCR or document quality. Those operations need their own input and output acceptance criteria.
Set authentication and resource limits
API credentials, limits and data classification
Document who may submit work, inspect status, retrieve results and cancel jobs. Check each action against the authenticated tenant and business scope. Knowing a job identifier should not itself grant permission to download its document.
If the chosen service uses OAuth bearer tokens, protect them in transit and storage. The bearer-token specification explains that possession can confer access and requires TLS for its HTTP use. RFC 6750 supports that requirement; the actual service still needs a verified credential and scope configuration. Keep tokens out of manifests and diagnostic messages.
| Contract input | Decision to record |
|---|---|
| Batch and item IDs | Stable identities independent of filenames |
| Input reference and checksum | Permitted bytes and provenance |
| Operation and configuration version | Exact work requested |
| Idempotency key | Which repeated request represents the same submission |
| Destination and result retention | Where results go and when access expires |
| Limits | File size, item count, concurrency and execution deadline |
| Atomicity | Independent items or a separate bundle-release rule |
Make limits visible before accepting large work. Distinguish a permanent input rejection from temporary capacity pressure. Agree what happens when an input URL expires while queued, whether the service copies accepted bytes, and how cancellation affects stored inputs. These are contract questions; a generic API label does not answer them.
An eight-item batch with one recoverable failure
Inputs, assumptions and the expected result
The synthetic batch contract defines batch SYN-B01, eight item IDs and operation page-count-v1. Items are independent. Valid inputs reuse an original three-page synthetic PDF; one item contains deliberately invalid text bytes. A transient failure, a pre-start cancellation and an item left queued are injected conditions.
A proposed asynchronous submission would return an accepted batch ID and a status reference, followed by per-item results. HTTP 202 Accepted specifically means processing has been accepted but is not complete; RFC 9110 also describes pointing the response towards a status monitor. See the HTTP semantics. The example does not send or receive HTTP messages.
| From | Condition | Next step |
|---|---|---|
| Accepted batch manifest | Always | Independent item jobs |
| Independent item jobs | Always | Item outcome |
| Item outcome | Success | Verified result manifest |
| Item outcome | Retryable failure | Bounded recovery attempt |
| Item outcome | Permanent or cancelled | Recorded terminal outcome |
| Bounded recovery attempt | Always | Independent item jobs |
The local exercise ran with Python 3.12.14 and pypdf 6.10.0. Its observed accounting was:
| Item state | After first pass | After eligible recovery |
|---|---|---|
| Succeeded | 4 | 5 |
| Retryable failure | 1 | 0 |
| Permanent failure | 1 | 1 |
| Cancelled before execution | 1 | 1 |
| Still queued | 1 | 1 |
| Total | 8 | 8 |
The five successful records each contained the correct three-page count and source checksum. Repeating their completed requests reused those records. The malformed input remained failed, and the deliberately queued item remained outstanding. The reconciliation log retains attempts, state transitions and outputs.
What the results establish
The run demonstrates local page-count extraction and item accounting under explicitly injected failures. It created no remote jobs and measured no service latency. It also uses in-memory state, so it does not establish recovery after a process restart, concurrent submissions or durable idempotency. Five outputs are the bounded result of this fixture, not a success-rate estimate for business PDFs.
Handle retries and partial failures
Idempotency, cancellation and failed items
Specify what a reused idempotency key means. A reasonable proposed rule is that the same scoped key and equivalent request recover the existing submission, while a changed payload under that key is rejected for review. Record how equivalence is determined and how long the key remains recoverable. A header named “idempotency” has no useful guarantee without those semantics.
After an uncertain submission response, query or reconcile the existing job before submitting again. Retrying the entire batch can duplicate successful work, increase cost and create competing result copies. Preserve item attempt history while giving the business one current outcome per requested operation.
Cancellation needs its own states. A request to cancel running work may arrive after output creation. Distinguish “cancellation requested” from “cancelled”, and specify whether an already completed output remains available. Do not equate cancellation with deletion or assume it reverses downstream actions.
Classify failures by the action required. Temporary resource pressure may permit a delayed retry. Invalid content, revoked access and an unsupported operation require different remedies. Cap automatic attempts and assign an owner when recovery is exhausted. A permanent error should not disappear from the denominator because the queue stopped trying it.
Acceptance checklist for a PDF processing API
Latency, failure rates and integrity checks
Test the complete contract against an authorised service environment. Use synthetic documents with known page counts and identifiable content, then introduce malformed input, an expired source reference, duplicate submission and interruption after acceptance. Include a cancellation race and a lost result response.
Record separate measurements for submission latency, queue time, processing time and final result retrieval. Define the denominator for each failure measure. In the example, five successful items out of eight submitted items is different from five out of six attempted items; neither should be presented without the cancelled and queued context.
Require the implementation to demonstrate:
- Every accepted item reaches a visible current state.
- Successful results identify the source and exact operation configuration.
- Retrieval checks the caller's authority for that result.
- A duplicate request does not create an unintended second operation.
- Restart recovery preserves completed work and unresolved attempts.
- Input and output checks detect missing, swapped or corrupt results.
- Expired access links can be handled without losing the underlying job identity.
For transformations, do not expect source and output checksums to match. Instead verify the expected change, preserve both checksums and apply operation-specific content checks. Integrity means the right output for the right input, not necessarily identical bytes.
Plan deployment and versioning
Backward compatibility and operational ownership
Version the request schema, state meanings and result manifest together. A client that understands only “succeeded” and “failed” may mishandle a new review state even when the JSON remains syntactically valid. Decide how older clients respond to unfamiliar states before changing the contract.
Assign owners for service availability, content-quality exceptions and batch reconciliation. Keep a recovery view that lists unresolved items by age and business deadline. Preserve the configuration attached to earlier jobs so operators can explain results after a deployment changes defaults.
Take the eight-item fixture and its accounting into a proof of concept. Ask the provider to demonstrate equivalent outcomes, actual authentication, restart recovery and measured completion under the intended load. Approve the workflow only when both successful outputs and unfinished work remain explainable.
Use idempotency keys in a PDF processing API
Keep the original request fingerprint with its idempotency key so a changed payload cannot silently inherit an earlier request’s result.
Read “Use idempotency keys in a PDF processing API”.
Handle partial failure in a batch PDF request
Track each file’s outcome and retry only unresolved work when a batch contains both completed and failed jobs.
Read “Handle partial failure in a batch PDF request”.
Return an output manifest for a PDF batch
Pair each input identifier with its outcome and available output so callers can reconcile a mixed-result batch without relying on file order.
Read “Return an output manifest for a PDF batch”.
Handle expired result links in a PDF API
Check the recorded job outcome before rerunning a conversion because an expired download link can belong to a successfully completed job.
Read “Handle expired result links in a PDF API”.
Sources
Published by Arke Technologies (Pty) Ltd, Johannesburg. Drafted with ChatGPT. Editorial and technical checks by Kairos (Codex). The linked articles were drafted with NotebookLM and independently checked and edited by Kairos (Codex).
