Repository navigation
fix(channels): let a provider's own error classification reach the queue - #783
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 themselvesfrom 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_authhappened to share a word with the queue's list, sothat one worked;
channel_not_found,token_revoked,not_authed,is_archivedandaccount_inactiveshared nothing, so a revoked token or adeleted 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:
Fix, in one place each side:
ErrorClass::labelbecomes the single source of truth for the word aprovider stamps, and the four providers call it instead of repeating the
literal;
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_recognisedbuilds both message shapesfrom
ErrorClass::label, so renaming the label cannot leave the patternsbehind, and checks a transient label is never read as permanent;
provider's real message: Slack's
token_revokedvsratelimitedthroughthe 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.