Repository navigation
Commit 81ff0ba
fix(search): do not return expired AWS credentials after a failed reload (#10042)
## What was wrong
`CachedCredentials::credentials` decided whether the cached AWS
credentials were still valid *before* awaiting the reload, which can
take a few seconds. If the reload then failed, it fell back to the
cached set using that earlier check, so it could return credentials that
had expired while the reload was running. The request signed with them
then failed at OpenSearch with a 403, not a clear credentials error.
## Fix
After a failed reload, check the cached set's expiry again against the
current time. Return it only if it is still valid; otherwise return the
reload error. The cache is otherwise unchanged.
## Testing
- New unit test
`credentials_that_expire_during_a_failed_reload_are_not_returned`. Its
source hands out credentials that expire 200 ms after loading, then
fails the reload only after they have expired. The call must return an
error.
- Confirmed the test fails with the fix reverted and passes with it.
- `cargo test -p buzz-search --lib aws_credentials`: 6 passed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Signed-off-by: Salman Mohammed <smohammed@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent a1ef23c commit 81ff0ba
1 file changed
Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
180 | 185 | | |
181 | 186 | | |
182 | 187 | | |
| |||
284 | 289 | | |
285 | 290 | | |
286 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
287 | 333 | | |
288 | 334 | | |
289 | 335 | | |
| |||
0 commit comments