Commit 463e519
committed
fix(virus-scanner): stop retrying 0-byte S3 objects and clarify logs
S3 has had strong read-after-write consistency since 2020, so a HeadObject
that reports ContentLength === 0 can never recover on retry. The previous
code retried 0-byte objects three times (wasted invocations) and logged the
failure as "Body is empty", which was misleading — the check is on
HeadObject.ContentLength, not a downloaded body.
s3.service.ts:
- Throw a typed ZeroByteS3ObjectError ("S3 object is 0 bytes") for the 0-byte
case and make it non-retryable via retryIf, so it short-circuits after one
attempt. 404 and missing-VersionId still retry as before
(MissingS3VersionIdError is now typed but remains retryable).
- Unwrap ts-retry-promise's RetryError to its original cause before rethrowing
(duck-typed, since the package's src/dist entry points make instanceof
unsafe under ts-jest) so callers can branch on the typed error.
- Drop the misleading "after retries" suffix from the failure log, since the
0-byte path no longer retries.
index.ts:
- Split the collapsed 404 warn into three distinguishable log lines with a
structured `reason` field: not_found, missing_version_id, zero_byte. The
HTTP response stays 404 with the same body, preserving caller behaviour.
Tests cover the 0-byte short-circuit (one attempt, no retry), the
missing-VersionId retry-then-fail path (four attempts, unchanged), and the
three distinct handler warn logs.
Closes #94811 parent a2a63d8 commit 463e519
4 files changed
Lines changed: 174 additions & 29 deletions
File tree
- services/virus-scanner-guardduty/src
- __tests
Lines changed: 49 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | | - | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
82 | | - | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| |||
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
98 | | - | |
99 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
105 | | - | |
| 110 | + | |
106 | 111 | | |
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
110 | 119 | | |
111 | 120 | | |
112 | | - | |
| 121 | + | |
113 | 122 | | |
114 | 123 | | |
115 | 124 | | |
| |||
125 | 134 | | |
126 | 135 | | |
127 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
128 | 161 | | |
129 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
130 | 171 | | |
131 | 172 | | |
132 | 173 | | |
| |||
Lines changed: 53 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
| |||
107 | 111 | | |
108 | 112 | | |
109 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
110 | 124 | | |
111 | 125 | | |
112 | 126 | | |
| |||
121 | 135 | | |
122 | 136 | | |
123 | 137 | | |
124 | | - | |
| 138 | + | |
125 | 139 | | |
126 | 140 | | |
127 | 141 | | |
128 | 142 | | |
129 | 143 | | |
130 | 144 | | |
131 | 145 | | |
132 | | - | |
| 146 | + | |
| 147 | + | |
133 | 148 | | |
134 | 149 | | |
135 | 150 | | |
136 | 151 | | |
137 | 152 | | |
138 | | - | |
| 153 | + | |
139 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
140 | 164 | | |
141 | 165 | | |
142 | 166 | | |
143 | | - | |
144 | | - | |
145 | | - | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
146 | 174 | | |
147 | 175 | | |
148 | 176 | | |
149 | 177 | | |
150 | 178 | | |
151 | | - | |
| 179 | + | |
152 | 180 | | |
153 | 181 | | |
154 | 182 | | |
155 | 183 | | |
156 | 184 | | |
157 | 185 | | |
158 | 186 | | |
159 | | - | |
160 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
161 | 192 | | |
162 | 193 | | |
163 | 194 | | |
164 | 195 | | |
165 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
166 | 199 | | |
| 200 | + | |
| 201 | + | |
167 | 202 | | |
168 | 203 | | |
169 | 204 | | |
170 | | - | |
171 | | - | |
172 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
173 | 212 | | |
174 | 213 | | |
175 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
69 | 89 | | |
70 | | - | |
| 90 | + | |
| 91 | + | |
71 | 92 | | |
72 | 93 | | |
73 | 94 | | |
| |||
| 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 | + | |
20 | 55 | | |
21 | 56 | | |
22 | 57 | | |
| |||
305 | 340 | | |
306 | 341 | | |
307 | 342 | | |
308 | | - | |
| 343 | + | |
309 | 344 | | |
310 | 345 | | |
311 | 346 | | |
312 | 347 | | |
313 | 348 | | |
314 | | - | |
| 349 | + | |
315 | 350 | | |
316 | 351 | | |
317 | 352 | | |
| |||
336 | 371 | | |
337 | 372 | | |
338 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
339 | 378 | | |
340 | 379 | | |
341 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
342 | 386 | | |
343 | 387 | | |
344 | 388 | | |
345 | 389 | | |
346 | 390 | | |
347 | 391 | | |
348 | 392 | | |
349 | | - | |
| 393 | + | |
350 | 394 | | |
351 | | - | |
| 395 | + | |
352 | 396 | | |
353 | 397 | | |
354 | | - | |
| 398 | + | |
355 | 399 | | |
356 | 400 | | |
357 | 401 | | |
0 commit comments