Antd.PartialUploadError exception (antd v0.4.1)

Copy Markdown View Source

An upload stored some chunks while others stayed unstored after the daemon's retries (HTTP 502 with code: "PARTIAL_UPLOAD"; gRPC ABORTED whose message starts with Partial upload:). The external-signer finalize functions return it, and so can daemon-wallet uploads (data_put, file_put and their _public variants): every REST and gRPC call shares one error mapping.

Error-contract change. This is its own exception module, not a subtype of Antd.NetworkError or Antd.AntdError. A partial store used to come back as %Antd.NetworkError{} (REST) or %Antd.AntdError{} (gRPC); it now returns, and the bang variants raise, %Antd.PartialUploadError{} on both transports, so a clause or rescue that names only those modules no longer catches it. Add a PartialUploadError clause, or rescue it alongside them; the README's "Migrating error handlers" section has before/after examples. Other 502s and other ABORTED statuses are unchanged.

The on-chain payment persists and the stored chunks stay on the network. How to finish the upload depends on retryable and retention_known (retryable implies retention_known):

  • retryable: true — the daemon kept the paid attempt (payment proofs plus the still-unstored chunks) under the same upload_id. Call the same finalize function again with the same upload_id and payment arguments to store the remainder against the same payment — no re-prepare, no second signature, no double payment. Bound that loop: a persistent failure returns this error on every call, so cap the attempts and treat a chunks_failed that stops shrinking as stuck. The retained attempt expires with the daemon's pending-upload TTL.
  • retention_known: true, retryable: false — the daemon confirmed it kept nothing (a daemon-wallet upload, or a merkle finalize with deliberately unpaid batches). Re-prepare the same content: stored chunks are skipped, so the retry pays only for the remainder.
  • retention_known: false — retention is unknown. The daemon may still hold the paid attempt (it records the resume handle before it returns the error), so stop automatic recovery, keep the upload_id and the original payment arguments, and reconcile before re-preparing or paying again. Never pay again on this signal alone. Daemons older than 0.14.0 never send retryable, so their REST partial uploads read as unknown.

Over REST the counts come from the structured error body, and retention_known is true only when the body's retryable is a JSON boolean (missing, null or any other type reads as unknown). Over gRPC they are parsed from the status message, Partial upload: S/T chunks stored, F failed after retries: <reason> (<hint>), where the closing hint starts paid attempt retained when the daemon kept the attempt and stored chunks persist; re-prepare the same content when it did not (daemons older than 0.14.0 write only the second). Only a message that starts with the Partial upload: prefix is a partial upload; an ABORTED that merely quotes it further in keeps the generic Antd.AntdError mapping. retention_known is true only when the message starts with the counts pattern, all three counts convert (each within the daemon's u64 range), and the message ends with one of the two hints; the hint then decides retryable. A pattern miss or a count that does not convert reads as 0 counts with both flags false. Readable counts with a missing, truncated or unrecognised hint keep the counts, but both flags stay false: retention unknown (stop and reconcile), not "nothing retained".

See docs/external-signer-flow.md §6 ("Retry a partial store — same upload_id, same payment") and finalize_with_retry/3 in examples/07_external_signer.exs.

Summary

Types

t()

@type t() :: %Antd.PartialUploadError{
  __exception__: true,
  chunks_failed: non_neg_integer(),
  chunks_stored: non_neg_integer(),
  message: String.t(),
  retention_known: boolean(),
  retryable: boolean(),
  status_code: integer(),
  total_chunks: non_neg_integer()
}