Sume job.completed has no error key; job.failed has payload null

A Sume job.completed webhook omits the error key entirely, while job.failed and job.canceled send payload null plus an error. How to branch without a KeyError.

3 min readSume
All posts

On a Sume job.completed webhook the error key is simply absent, and on job.failed and job.canceled the payload is null and error is present. So read it with a default, such as body.get("error"), and branch on the event field first.

Both failure events carry status ERROR, so the status value cannot tell failed from canceled; the event name can.

The three shapes

These follow the webhook code and docs.

Payload by event (read 2026-10-06, Sume docs and repo)
Eventstatuspayloaderror
job.completedOKResult objectKey absent
job.failedERRORnullPresent
job.canceledERRORnullPresent

Why absent, not null

The code leaves error undefined on success, and JSON serialization drops undefined keys. Code that does body["error"] raises KeyError in Python, and code that checks error === null in JavaScript misses it, because the key is undefined, not null. Test for presence or for a falsy value.

A branch that works

Switch on event. For job.completed, take payload. For job.failed, log error and read GET /v1/jobs/{id} for the full record. For job.canceled, mark the work stopped and do not retry automatically, since someone or something chose to cancel it.

Failures refund reserved credits, so a failed event is not a charge you need to dispute.

In Python, a small function that takes the parsed body and returns a tuple of ('ok', payload) or ('error', error) keeps the rest of your code free of key checks. In TypeScript, model the payload as a union keyed on event, so the compiler forces you to handle the missing error key. Whatever the language, write one test per event with a fixture copied from a real delivery, and a fourth test for an unknown event name, which should be rejected after the signature check and not silently accepted.

Tradeoffs

Being strict about the shape breaks on future fields; being lax can hide a malformed delivery. Verify the signature first, then check that event is one of the three you know and reject others loudly.

Keep the raw body you verified, too. If a branch misbehaves later, a stored copy of the exact delivery, with its timestamp header, lets you replay it through the same code and see which shape arrived, which beats guessing from a log line that printed only part of it.

Sources

Related posts

More in Developers

All Developers posts

Written by Sume