ADR 0319: The publishing adapters implement the worker's delivery contract and never copy provider text
- Status: Accepted
- Date: 2026-10-29
- Parent epic: #353
- Story: #358 (task #373)
Context#
The delivery worker (story #357; ADRs 0316 to 0318) claims a due announcement, opens the account's credential
(ADR 0295) and calls the provider through one adapter interface, documented at the top of
netlify/lib/social-delivery.mjs. It must not duplicate a post, must not mark one published without proof and must
not leak a token or a provider's text. The LinkedIn and Facebook adapters are the first real implementations of that
interface, so they follow it exactly instead of defining a second one.
Decision#
- The worker's interface, nothing else.
netlify/lib/social-publish.mjsexportslinkedinAdapter(settings, { fetchImpl, now })andfacebookAdapter(...); each returns{ provider, publish, reconcile? }.publish({ post, account, accessToken, signal })receivespost={ id, idempotencyKey, caption, canonicalUrl, work }andaccount={ provider, kind, externalId, displayName }from the worker and nothing else of ours. - Success is a value, every other outcome a typed throw.
publishresolves to{ providerPostId }only when the provider confirmed success and named the post with an id of its own shape (LinkedInurn:li:share|ugcPost:<n>fromx-restli-id). Anything else throws aDeliveryError(ADR 0317) whosekindthe worker switches on (ADR 0318):auth: 401, or a token that is missing or not printable (no request is made). The worker fails the post withneeds-reauthand moves the account fromconnectedtoneeds-reauth(the same guarded update the credential store makes when a refresh is refused), so its other announcements fail before any send and Admin asks the author to connect again.rejected: 400, 403, 404, 409, 410, 422 and any other 4xx: the provider read the request and refused it. Also a post the adapter cannot send at all (a destination id not of the provider's shape, a caption that fails the schedule rules of ADR 0308, a link that is not plainhttps); no request is made.rate-limited: 429, withretryAfterMsfromRetry-After(seconds or an HTTP date, viaparseRetryAfter); the worker caps it and pauses the account.transient: the request certainly never left: the signal was already aborted, the host did not resolve (ENOTFOUND,EAI_AGAIN), the connection was refused or never established (ECONNREFUSED, connect timeout).uncertain: it may have posted: a 2xx without a usable id, a 5xx, a 3xx (never followed), a timeout or abort after the request left, a dropped connection, an unreadable answer. The worker never re-sends it.
- The worker's signal bounds the call. The
signalit passes (its provider timeout) is handed tofetch; the adapter does not retry, and makes exactly one provider call perpublish. - No idempotency key is sent. Neither the LinkedIn Posts API nor the Graph Page feed honours one on these calls,
so
idempotencyKeyis not sent and nothing relies on it. Duplicates are prevented by the rule above instead: only an answer that means "definitely not processed" (transient,rate-limited) is retried; anything that may have posted isuncertain. - Reconcile only where a read-only lookup exists. Facebook implements
reconcile(ADR 0320). LinkedIn omits it: listing a member's or organization's posts (GET /rest/posts?q=author) needsr_member_socialorr_organization_social, which LinkedIn grants only to approved partners and this deployment never requests. An unknown LinkedIn outcome therefore goes to a person straight away (needs-review, ADR 0318). - Registered only when configured.
socialAdapters({ providers, fetchImpl, now })(innetlify/lib/social-adapters.mjs) registers an adapter only for a provider thatsocialProviders(env)reports as configured (client id, secret and a valid API version, ADR 0299), in a frozen object with no prototype. With none configured it is empty and every announcement waits in the queue (ADR 0317): delivery is off by default. The worker looks an adapter up by own property only. - Nothing a provider said is copied. A reply is read for a status, a few headers and an id; an error carries
only its kind, the HTTP status and the fixed sentence of
social-delivery.mjs. The token travels only in theAuthorizationheader. The adapters never log. - LinkedIn request.
POST {apiBase}/rest/postswithAuthorization: Bearer,Linkedin-Version(the configured dated version) andX-Restli-Protocol-Version: 2.0.0; none of the obsoleteX-Li-FormatorugcPostsshape. The body is aPUBLICMAIN_FEEDpost by the account's member or organization URN with anarticle(sourcethe canonical link,titlethe caption's first line, at most 200 characters, or "Read the full post"),lifecycleState: PUBLISHED.commentaryis LinkedIn "little text", so\ | { } @ [ ] ( ) < > # * _ ~are escaped: a caption posts as typed and cannot mention or format.
Considered options#
- Return a status object (
published/failed/unknown) instead of throwing. This was the first draft. It was rejected because it contradicted the interface the worker already defines (ADRs 0316 to 0318): two shapes would need a translation layer in which a mapping mistake duplicates or hides a post. The worker'sDeliveryErrorkinds already separate a refusal from an ambiguous outcome, and a plain throw is treated asuncertain, so a mistake fails safe. - Treat a 5xx or any network error as retryable. Rejected: a gateway can time out after the post was created.
Only errors that happen before the request is sent are
transient. - Send the idempotency key in a custom header anyway. Rejected: a header a provider ignores gives false comfort.
- Copy the provider's error message to help the author. Rejected: it is untrusted text that may echo secrets.
Consequences#
- Every LinkedIn
uncertainbecomes a person's decision in Admin; that is the price of never duplicating. - A new network is a code change in
providerOf,social-publish.mjsand its fixture cases, on purpose.