Skip to content

fix(channels): let a provider's own error classification reach the queue - #783

Merged
huichen merged 1 commit into
mainfrom
fix/chan-permanent-label
Sep 22, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/chan-permanent-label

Conversation

@huichen

@huichen huichen commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

fix(channels): let a provider's own error classification reach the queue

The durable delivery queue stores a failed send's message text and decides
whether to keep retrying from that text alone
(delivery::is_permanent_error). Four providers classify a failure themselves
from the platform's error code and stamp the answer into the message — but the
queue did not recognise the stamp. Its vocabulary matched platform prose
("channel not found", "invalid token"), so a provider's label was decoration:
the retry decision was re-derived from whatever words the platform used.

The gap was invisible because it only bites on the codes nobody wrote prose
for. Slack's invalid_auth happened to share a word with the queue's list, so
that one worked; channel_not_found, token_revoked, not_authed,
is_archived and account_inactive shared nothing, so a revoked token or a
deleted channel was retried to the attempt cap. Linq was worse off: its
classification comes from numeric codes that no pattern can match at all, so
every permanent Linq failure was retried until the cap. WhatsApp and Signal
were in between — recognised only when the platform's own text happened to
contain a pattern word.

Measured before the change, with neutral platform text:

slack "not_authed (permanent error)"      -> is_permanent = false
linq  "rejected (permanent): ..."          -> is_permanent = false
whatsapp "rejected (permanent): ..."       -> is_permanent = false
signal "failed: peer refused (permanent error)" -> is_permanent = false

Fix, in one place each side:

  • ErrorClass::label becomes the single source of truth for the word a
    provider stamps, and the four providers call it instead of repeating the
    literal;
  • the queue recognises the parenthesised label it stores, so the provider's
    decision survives. Parenthesised on purpose: a platform's own prose will not
    contain (permanent) by accident.

Tests, all of which fail without the fix (verified by removing the patterns and
watching all five go red):

  • the_provider_classification_label_is_recognised builds both message shapes
    from ErrorClass::label, so renaming the label cannot leave the patterns
    behind, and checks a transient label is never read as permanent;
  • one per provider, asserting the classification reaches the queue through the
    provider's real message: Slack's token_revoked vs ratelimited through
    the API path, Linq's 400-with-empty-body, WhatsApp's, and Signal's 404 whose
    body says only "no such route". Those providers previously had no such
    assertion; the five that did are the reason this stayed confined.

The provider contract now states the requirement ("put the class in the message
text"), which is the part that would have prevented it recurring in the next
provider.

No behaviour change for a send that works; a permanent failure now stops at the
first attempt instead of the last, and the queue's own pattern list is
untouched.

The durable delivery queue stores a failed send's message text and decides
whether to keep retrying from that text alone
(`delivery::is_permanent_error`). Four providers classify a failure themselves
from the platform's error code and stamp the answer into the message — but the
queue did not recognise the stamp. Its vocabulary matched platform prose
("channel not found", "invalid token"), so a provider's label was decoration:
the retry decision was re-derived from whatever words the platform used.

The gap was invisible because it only bites on the codes nobody wrote prose
for. Slack's `invalid_auth` happened to share a word with the queue's list, so
that one worked; `channel_not_found`, `token_revoked`, `not_authed`,
`is_archived` and `account_inactive` shared nothing, so a revoked token or a
deleted channel was retried to the attempt cap. Linq was worse off: its
classification comes from numeric codes that no pattern can match at all, so
every permanent Linq failure was retried until the cap. WhatsApp and Signal
were in between — recognised only when the platform's own text happened to
contain a pattern word.

Measured before the change, with neutral platform text:

    slack "not_authed (permanent error)"      -> is_permanent = false
    linq  "rejected (permanent): ..."          -> is_permanent = false
    whatsapp "rejected (permanent): ..."       -> is_permanent = false
    signal "failed: peer refused (permanent error)" -> is_permanent = false

Fix, in one place each side:

- `ErrorClass::label` becomes the single source of truth for the word a
  provider stamps, and the four providers call it instead of repeating the
  literal;
- the queue recognises the parenthesised label it stores, so the provider's
  decision survives. Parenthesised on purpose: a platform's own prose will not
  contain `(permanent)` by accident.

Tests, all of which fail without the fix (verified by removing the patterns and
watching all five go red):

- `the_provider_classification_label_is_recognised` builds both message shapes
  from `ErrorClass::label`, so renaming the label cannot leave the patterns
  behind, and checks a transient label is never read as permanent;
- one per provider, asserting the classification reaches the queue through the
  provider's *real* message: Slack's `token_revoked` vs `ratelimited` through
  the API path, Linq's 400-with-empty-body, WhatsApp's, and Signal's 404 whose
  body says only "no such route". Those providers previously had no such
  assertion; the five that did are the reason this stayed confined.

The provider contract now states the requirement ("put the class in the message
text"), which is the part that would have prevented it recurring in the next
provider.

No behaviour change for a send that works; a permanent failure now stops at the
first attempt instead of the last, and the queue's own pattern list is
untouched.
@huichen
huichen enabled auto-merge (squash) September 22, 2026 16:56
@huichen
huichen merged commit 9344ca7 into main Sep 22, 2026
12 checks passed
@huichen
huichen deleted the fix/chan-permanent-label branch September 22, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant