You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 099f461
Browse filesBrowse the repository at this point in the historyBrowse files
Improve HTTP response handling and retry logic (#520)
Unified HTTP response handling and retry behavior
Brings analytics-python in line with the TAPI HTTP agreements and with
analytics-java 3.5.5.
Upgrade note: proxies and header allowlists
This release sends two request headers that earlier versions did not:
Authorization (HTTP Basic, carrying the write key) and X-Retry-Count
(on retries only). If traffic to Segment passes through a proxy,
gateway or WAF that allowlists request headers, add both before
upgrading or uploads will be rejected. The equivalent change in the
already-released analytics-next had exactly this effect on customers.
Headers
- Send the write key as Authorization: Basic base64("<writeKey>:"). It
remains in the request body, so no server-side change is required.
OAuth deployments continue to send Bearer and are unaffected.
- Send X-Retry-Count on retries, omitted on the first attempt, so the
server can distinguish a retry from a first try.
Retry behavior
- Retryable statuses: 408, 410, 429, 460 and 5xx except 501 and 505.
511 asks the client to re-authenticate, so it is retried only when an
OauthManager is configured, clearing the stale token first.
- Retry-After is honored on every retryable status rather than 429
alone, which brings 529 in through the generic 5xx rule. Numeric
seconds and the RFC 7231 HTTP-date formats are both accepted, capped
at 300s. Naive datetimes are read as UTC; servers emit the RFC 5322
"-0000" offset, and reading it as local time made a future date parse
Copy file name to clipboardExpand all lines: HISTORY.md
+19Lines changed: 19 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,22 @@
1
+
# Unreleased
2
+
### Upgrade note: new request headers and proxy allowlists
3
+
This release sends two request headers that earlier versions did not:
4
+
`Authorization` (HTTP Basic, carrying your write key) and `X-Retry-Count`
5
+
(on retries only). If your traffic to Segment goes through a proxy, gateway
6
+
or WAF that allowlists request headers, add both before upgrading or uploads
7
+
will be rejected.
8
+
9
+
- Send the write key as an `Authorization: Basic` header. It is still included in the request body, so no server-side change is required. OAuth deployments continue to send `Authorization: Bearer` and are unaffected.
10
+
- Send `X-Retry-Count` on retries, so the server can distinguish a retry from a first attempt. Omitted on the first attempt.
11
+
- Unified retry handling: 429, 408, 410, 460 and 5xx (except 501 and 505) are retried. `Retry-After` is honoured on all of them, not just 429, which brings 529 in through the generic 5xx rule. 511 asks the client to re-authenticate, so it is retried only when an `oauth_manager` is configured and is dropped otherwise.
12
+
-`Retry-After` accepts numeric seconds and the RFC 7231 HTTP-date formats, capped at 300s.
13
+
- Rate-limited retries are bounded by elapsed time rather than counted against the retry limit, so a long `Retry-After` no longer exhausts the budget.
14
+
- New client options `max_total_backoff_duration` and `max_rate_limit_duration` (default 12 hours each) bound the two waits.
15
+
- Only 2xx responses count as a successful upload. A 3xx is now reported as a failed upload rather than silently treated as delivered. It is not retried: a redirect the HTTP client already declined to follow will not succeed on a retry. The Segment endpoint does not redirect, so this only affects custom `host` values.
16
+
- Backoff waits are interruptible, so `shutdown()` no longer blocks for the full delay.
17
+
- Retry timing uses a monotonic clock, so a system clock change cannot stretch or collapse a backoff.
18
+
- Fix a `queue.task_done()` leak that could leave `flush()` waiting forever when a batch was re-queued during shutdown.
19
+
1
20
# 2.3.6 / 2026-4-7
2
21
- Update and widen PyJWT version to address security issue
Copy file name to clipboardExpand all lines: e2e-cli/README.md
+24-6Lines changed: 24 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,35 @@
2
2
3
3
E2E test CLI for the [analytics-python](https://github.com/segmentio/analytics-python) SDK. Accepts a JSON input describing events and SDK configuration, sends them through the real SDK, and outputs results as JSON.
4
4
5
-
## Setup
5
+
## Running E2E tests
6
+
7
+
### With devbox (recommended)
8
+
9
+
```bash
10
+
# From repo root — activates Python 3.12 and installs deps automatically
11
+
devbox shell
12
+
13
+
# Then from e2e-cli dir:
14
+
./run-e2e.sh
15
+
```
16
+
17
+
### Without devbox
18
+
19
+
Requires Python 3.9+ and Node.js 18+. Using a virtualenv is strongly recommended since macOS system Python is externally managed.
0 commit comments