Skip to content

Commit

Permalink
Fix S3 canary match statement (#2358)
Browse files Browse the repository at this point in the history
* fix: s3 canary error match

* update: use Error.is_ to check for "no such key" error in canary

* remove: leftover import
  • Loading branch information
Velfi authored and jjant committed Feb 14, 2023
1 parent 76c8f29 commit f0c3291
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tools/ci-cdk/canary-lambda/src/s3_canary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::{mk_canary, CanaryEnv};
use anyhow::Context;
use aws_config::SdkConfig;
use aws_sdk_s3 as s3;
use s3::error::{GetObjectError, GetObjectErrorKind};
use s3::types::ByteStream;
use uuid::Uuid;

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

// Put the test object
Expand Down

0 comments on commit f0c3291

Please sign in to comment.