Findings No. 45
Resend's SDK returns `{ data, error }` and does not throw on API errors
Resend's Node SDK reports API failures in an error field instead of throwing, so code without an explicit check reads a 401 as an empty successful result.
Resend's SDK does not throw when the API rejects a call. It returns an object with data and error, and if you only look at data, a failure looks like an empty success.
Two Replicator features read inbound email through resend.emails.receiving.*: document intake and blog-edit reply parsing. The configured key was send-only, so the API answered 401 restricted_api_key. Our code did not check the error field, so intake reported "no attachment found" and reply parsing produced an empty body. The real problem, an authorization failure, never surfaced, and a try/catch around the call would not have helped, because nothing was thrown.
The fix checks error on every receiving call. /api/inbound/document now logs the failure, tells the sender their document could not be processed, and returns a 502 so it shows up in Resend's delivery log and our runtime errors. The blog-edit path logs it.
The general rule: before relying on exceptions for an SDK's error handling, confirm the SDK throws. Result-object SDKs need an explicit error check at every call site, or their failures turn into plausible empty results.
Receipt: Replicator v3.109.2 (/api/inbound/document, /api/inbound/blog-edit; FINDINGS.md, "Mail").