Commit 74dfe94
Retry all 5xx server errors (MAGE-694) (#485)
* Retry all 5xx server errors (MAGE-694)
Widen the retryable classification from {429,500,502,503,504} to 429 plus the
full 5xx range (500-599). This covers transient CDN/edge failures such as
Cloudflare's 520-527 codes, which were observed during the
cannot-access-klaviyo-com incident and had zero overlap with the old allowlist,
causing data loss for the duration of the outage. 4xx codes (including 403
load-shed) remain non-retryable so the backend can still shed load.
Adds tests for Cloudflare 522/525 and the 599 upper bound.
🤖 Generated with Reca
* refine(analytics): exclude 501/505 from retryable 5xx + add bounds tests (MAGE-694)
501 (Not Implemented) and 505 (HTTP Version Not Supported) are permanent,
deterministic server errors — retrying the identical request always fails the
same way — so classify them as non-retryable (Failed) like a 4xx, via a
501, 505 -> branch placed before the in 500..599 retryable branch. The rest of
5xx (429 + 500..599 except 501/505) stays retryable.
Adds tests: 501/505 non-retryable, plus 499 (lower-bound) and 600 (upper-bound)
sanity checks that just-outside-5xx codes remain non-retryable.
-Claude
* refactor(analytics): name 5xx status constants + dedup boundary tests (CodeRabbit)
Extract named constants for the previously-inlined HTTP status literals in
parseResponse's when(responseCode): HTTP_NOT_IMPLEMENTED (501),
HTTP_VERSION_NOT_SUPPORTED (505), and the HTTP_5XX_RETRYABLE_RANGE (500..599)
range, placed alongside the existing HTTP_RETRY const. Behavior is identical.
De-dup the single-send status-code tests behind a shared
assertStatusForResponseCode(responseCode, expected) helper, removing the
repeated mock/send/assert boilerplate while keeping the distinct, readable
per-code test methods and their explanatory comments. Coverage is unchanged.
-Claude
* revert(analytics): retry entire 5xx range incl 501/505 (drop permanent-error exclusion) (MAGE-694)
An earlier commit excluded 501 (Not Implemented) and 505 (HTTP Version Not
Supported) as "permanent" server errors. Reverting that: for the SDK's fixed
request shapes over the HTTP versions Klaviyo supports, a genuine origin 501/505
is effectively unreachable, so any 5xx we actually observe is almost certainly
edge/CDN/proxy noise during an incident — exactly what MAGE-694 wants to retry.
The incident data-retention benefit outweighs the negligible wasted-retry cost
on codes we will never legitimately see.
- Drop the 501/505 -> Status.Failed when-branch so they fall through to the
retryable HTTP_5XX_RETRYABLE_RANGE branch like the rest of 500–599.
- Remove the now-unused HTTP_NOT_IMPLEMENTED / HTTP_VERSION_NOT_SUPPORTED
constants; keep HTTP_5XX_RETRYABLE_RANGE and HTTP_RETRY.
- Flip the 501/505 tests to assert PendingRetry and document the deliberate
retry. 499/600 bounds tests remain non-retryable. 4xx (incl. 403) unchanged.
-Claude
---------
Co-authored-by: Reca <reca@klaviyo.com>1 parent 1cb6733 commit 74dfe94
2 files changed
Lines changed: 78 additions & 49 deletions
File tree
- sdk/analytics/src
- main/java/com/klaviyo/analytics/networking/requests
- test/java/com/klaviyo/analytics/networking/requests
Lines changed: 11 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
72 | 73 | | |
73 | 74 | | |
74 | 75 | | |
| |||
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
435 | | - | |
436 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
| |||
Lines changed: 67 additions & 47 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
78 | 92 | | |
79 | 93 | | |
80 | 94 | | |
| |||
722 | 736 | | |
723 | 737 | | |
724 | 738 | | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
| 739 | + | |
731 | 740 | | |
732 | 741 | | |
733 | 742 | | |
734 | 743 | | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
| 744 | + | |
741 | 745 | | |
742 | 746 | | |
743 | 747 | | |
744 | 748 | | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
| 749 | + | |
751 | 750 | | |
752 | 751 | | |
753 | 752 | | |
754 | 753 | | |
755 | | - | |
756 | | - | |
| 754 | + | |
| 755 | + | |
757 | 756 | | |
758 | | - | |
759 | | - | |
760 | | - | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
761 | 801 | | |
762 | 802 | | |
763 | 803 | | |
| |||
778 | 818 | | |
779 | 819 | | |
780 | 820 | | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
| 821 | + | |
787 | 822 | | |
788 | 823 | | |
789 | 824 | | |
790 | 825 | | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
| 826 | + | |
797 | 827 | | |
798 | 828 | | |
799 | 829 | | |
800 | 830 | | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
| 831 | + | |
807 | 832 | | |
808 | 833 | | |
809 | 834 | | |
810 | 835 | | |
811 | | - | |
812 | | - | |
813 | | - | |
814 | | - | |
815 | | - | |
816 | | - | |
| 836 | + | |
817 | 837 | | |
818 | 838 | | |
0 commit comments