Commit 865d217
fix: correctness and security hardening across pipeline, transports, and serde
Resolve a batch of correctness and security issues found while reviewing the
HTTP stack end to end.
Pipeline & auth:
- Credential policies are origin-aware: after a cross-origin redirect the
bearer/basic/key credential is no longer re-stamped onto the foreign host,
and the redirect policy strips a caller-set Authorization only on
cross-origin hops (same-origin hops keep it).
- Retry decides single-use body buffering from the effective per-call retry
total and no longer retries non-idempotent methods on read-phase errors;
async body buffering runs off the event loop.
- Pipeline construction rejects reuse of a policy instance already wired into
another pipeline.
Transports:
- requests: never emit Content-Length and Transfer-Encoding together; frame
known-length bodies by length (streamed, not buffered into memory) and chunk
unknown-length bodies with any stale Content-Length removed. Close only a
session the client owns; preserve repeated response headers; report the
negotiated HTTP version; drop a misleading Content-Length under
Content-Encoding.
- urllib: stop following redirects inside the transport so the 3xx reaches the
pipeline; map response-read failures into the SDK error hierarchy.
- asyncio: send Host with the port for non-default ports; apply an SSL context
only to https URLs; reject chunked and read connection-close framing instead
of fabricating an empty body; detect chunked across multiple
Transfer-Encoding lines; buffer the request body off the event loop.
- httpx/aiohttp: set Content-Length for known-length bodies and pump sync body
iterators on a worker thread.
- All transports preserve a valid-but-unregistered status code instead of
discarding the response.
Serde, pagination, streaming, multipart:
- Codec decodes Annotated[...] fields (including annotated Tristate) correctly,
guards recursion depth, and wraps conversion failures in CodecError.
- Link-header pagination reads every Link line and tolerates commas inside the
target URI; cursor pagination accepts non-string cursors; JSON page parsing
surfaces DeserializationError.
- JSONL and SSE decoding map invalid UTF-8 onto the streaming error contract.
- Multipart rejects CR/LF/NUL in field names, filenames, media types, custom
part headers, and the boundary to prevent header injection.
Also fixes the digest nonce-count reset, per-operation tracing event emission,
URL-redactor fail-closed behaviour, proxy configuration parsing, and a number
of smaller correctness and documentation issues. Adds regression tests
throughout; the full suite, mypy --strict, and ruff all pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 526ecc7 commit 865d217
86 files changed
Lines changed: 5922 additions & 409 deletions
File tree
- packages
- dexpace-sdk-core
- src/dexpace/sdk/core
- http
- auth
- common
- context
- request
- response
- sse
- instrumentation
- pagination
- pipeline
- policies
- serde
- util
- tests
- auth
- http
- instrumentation
- pagination
- pipeline
- serde
- sse
- util
- dexpace-sdk-http-aiohttp
- src/dexpace/sdk/http/aiohttp
- tests
- dexpace-sdk-http-httpx
- src/dexpace/sdk/http/httpx
- tests
- dexpace-sdk-http-requests
- src/dexpace/sdk/http/requests
- tests
- dexpace-sdk-http-stdlib
- src/dexpace/sdk/http/stdlib
- tests
- tools
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 43 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
58 | 62 | | |
59 | 63 | | |
60 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
| |||
79 | 90 | | |
80 | 91 | | |
81 | 92 | | |
82 | | - | |
83 | 93 | | |
| 94 | + | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
| |||
102 | 113 | | |
103 | 114 | | |
104 | 115 | | |
105 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
106 | 120 | | |
107 | 121 | | |
108 | 122 | | |
| |||
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
125 | | - | |
| 139 | + | |
126 | 140 | | |
127 | 141 | | |
128 | 142 | | |
| |||
223 | 237 | | |
224 | 238 | | |
225 | 239 | | |
226 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
227 | 257 | | |
228 | 258 | | |
229 | 259 | | |
230 | 260 | | |
231 | | - | |
232 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
233 | 267 | | |
234 | 268 | | |
235 | 269 | | |
| |||
Lines changed: 87 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
42 | 48 | | |
43 | 49 | | |
44 | 50 | | |
| |||
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
| 72 | + | |
| 73 | + | |
66 | 74 | | |
67 | 75 | | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
71 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
| |||
79 | 94 | | |
80 | 95 | | |
81 | 96 | | |
| 97 | + | |
| 98 | + | |
82 | 99 | | |
83 | 100 | | |
84 | 101 | | |
| |||
91 | 108 | | |
92 | 109 | | |
93 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
94 | 118 | | |
95 | 119 | | |
96 | 120 | | |
| |||
226 | 250 | | |
227 | 251 | | |
228 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
229 | 258 | | |
230 | 259 | | |
231 | 260 | | |
| |||
257 | 286 | | |
258 | 287 | | |
259 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
260 | 296 | | |
261 | 297 | | |
262 | 298 | | |
| |||
381 | 417 | | |
382 | 418 | | |
383 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
384 | 425 | | |
385 | 426 | | |
386 | 427 | | |
| |||
398 | 439 | | |
399 | 440 | | |
400 | 441 | | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
401 | 487 | | |
402 | 488 | | |
403 | 489 | | |
| |||
Lines changed: 42 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
20 | 61 | | |
21 | 62 | | |
22 | 63 | | |
| |||
146 | 187 | | |
147 | 188 | | |
148 | 189 | | |
149 | | - | |
| 190 | + | |
150 | 191 | | |
151 | 192 | | |
152 | 193 | | |
| |||
0 commit comments