Skip to content

Commit c94c604

Browse files
Zelda Hesslerjjant
authored andcommitted
Fix S3 canary match statement (#2358)
* fix: s3 canary error match * update: use Error.is_ to check for "no such key" error in canary * remove: leftover import
1 parent f074561 commit c94c604

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tools/ci-cdk/canary-lambda/src/s3_canary.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use crate::{mk_canary, CanaryEnv};
88
use anyhow::Context;
99
use aws_config::SdkConfig;
1010
use aws_sdk_s3 as s3;
11-
use s3::error::{GetObjectError, GetObjectErrorKind};
1211
use s3::types::ByteStream;
1312
use uuid::Uuid;
1413

@@ -35,15 +34,13 @@ pub async fn s3_canary(client: s3::Client, s3_bucket_name: String) -> anyhow::Re
3534
CanaryError(format!("Expected object {} to not exist in S3", test_key)).into(),
3635
);
3736
}
38-
Err(err) => match err.into_service_error() {
39-
GetObjectError {
40-
kind: GetObjectErrorKind::NoSuchKey(..),
41-
..
42-
} => {
43-
// good
37+
Err(err) => {
38+
let err = err.into_service_error();
39+
// If we get anything other than "No such key", we have a problem
40+
if !err.is_no_such_key() {
41+
return Err(err).context("unexpected s3::GetObject failure");
4442
}
45-
err => Err(err).context("unexpected s3::GetObject failure")?,
46-
},
43+
}
4744
}
4845

4946
// Put the test object

0 commit comments

Comments
 (0)