Skip to content

Commit 3689b94

Browse files
committed
fix(validator): accept newer AWS regions like eu-central-2
rusoto_core 0.48.0 (abandoned) hardcoded the set of known AWS regions and rejected anything launched after its last release, surfacing as "Not a valid AWS region: eu-central-2" when parsing the validator's checkpointSyncer config or the relayer's S3 storage location URL. aws_types::Region is an intentional pass-through newtype — the SDK does not validate region strings because new regions launch regularly and private partitions have non-public ones. A bogus region fails at the first API call with a clear endpoint error, so no client-side validation is needed. Drop the rusoto-based check and pass the string straight through.
1 parent e63aeea commit 3689b94

2 files changed

Lines changed: 25 additions & 15 deletions

File tree

rust/main/agents/validator/src/settings.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,12 @@ fn parse_checkpoint_syncer(syncer: ValueParser) -> ConfigResult<CheckpointSyncer
293293
.parse_string()
294294
.end()
295295
.map(str::to_owned);
296-
// Using rusoto_core::Region just to get some input validation
297-
let region: Option<rusoto_core::Region> = syncer
296+
let region: Option<String> = syncer
298297
.chain(&mut err)
299298
.get_key("region")
300-
.parse_from_str("Expected aws region")
301-
.end();
299+
.parse_string()
300+
.end()
301+
.map(str::to_owned);
302302
let folder = syncer
303303
.chain(&mut err)
304304
.get_opt_key("folder")
@@ -309,7 +309,7 @@ fn parse_checkpoint_syncer(syncer: ValueParser) -> ConfigResult<CheckpointSyncer
309309
cfg_unwrap_all!(&syncer.cwp, err: [bucket, region]);
310310
err.into_result(CheckpointSyncerConf::S3 {
311311
bucket,
312-
region: Region::new(region.name().to_owned()),
312+
region: Region::new(region),
313313
folder,
314314
})
315315
}

rust/main/hyperlane-base/src/settings/checkpoint_syncer.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{env, path::PathBuf};
22

33
use aws_config::Region;
44
use core::str::FromStr;
5-
use eyre::{eyre, Context, Report, Result};
5+
use eyre::{eyre, Report, Result};
66
use prometheus::IntGauge;
77
use tracing::error;
88
use ya_gcp::{AuthFlow, ServiceAccountAuth};
@@ -79,15 +79,7 @@ impl FromStr for CheckpointSyncerConf {
7979
Ok(CheckpointSyncerConf::S3 {
8080
bucket: bucket.into(),
8181
folder,
82-
// Wildly, aws_config doesn't provide any client-side way to validate a region string, so while
83-
// we still have Rusoto around we just use that to validate the region string :)
84-
region: aws_config::Region::new(
85-
region
86-
.parse::<rusoto_core::Region>()
87-
.context("Invalid region when parsing storage location")?
88-
.name()
89-
.to_owned(),
90-
),
82+
region: aws_config::Region::new(region.to_owned()),
9183
})
9284
}
9385
"file" => Ok(CheckpointSyncerConf::LocalStorage {
@@ -290,4 +282,22 @@ mod test {
290282
_ => panic!("Expected a reorg event error"),
291283
}
292284
}
285+
286+
#[test]
287+
fn test_parse_s3_storage_location_with_new_region() {
288+
use super::*;
289+
let conf = CheckpointSyncerConf::from_str("s3://my-bucket/eu-central-2/folder").unwrap();
290+
match conf {
291+
CheckpointSyncerConf::S3 {
292+
bucket,
293+
folder,
294+
region,
295+
} => {
296+
assert_eq!(bucket, "my-bucket");
297+
assert_eq!(folder.as_deref(), Some("folder"));
298+
assert_eq!(region.as_ref(), "eu-central-2");
299+
}
300+
_ => panic!("Expected S3 checkpoint syncer"),
301+
}
302+
}
293303
}

0 commit comments

Comments
 (0)