Skip to content

Commit 26b2ec0

Browse files
authored
fix: error handling on server start when s3 bucket is not found (#609)
fixes #574
1 parent 238b9ae commit 26b2ec0

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

server/src/storage.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ pub enum ObjectStorageError {
140140
#[error("{0} not found")]
141141
NoSuchKey(String),
142142

143+
// custom
144+
#[error("{0}")]
145+
Custom(String),
146+
143147
// Could not connect to object storage
144148
#[error("Connection Error: {0}")]
145149
ConnectionError(Box<dyn std::error::Error + Send + Sync + 'static>),

server/src/storage/s3.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,15 @@ impl S3 {
256256
.with_label_values(&["PUT", status])
257257
.observe(time);
258258

259+
if let Err(object_store::Error::NotFound { source, .. }) = &resp {
260+
let source_str = source.to_string();
261+
if source_str.contains("<Code>NoSuchBucket</Code>") {
262+
return Err(ObjectStorageError::Custom(
263+
format!("Bucket '{}' does not exist in S3.", self.bucket).to_string(),
264+
));
265+
}
266+
}
267+
259268
resp.map(|_| ()).map_err(|err| err.into())
260269
}
261270

server/src/storage/store_metadata.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ pub async fn resolve_parseable_metadata() -> Result<StorageMetadata, ObjectStora
156156
ObjectStorageError::UnhandledError(err)
157157
})?;
158158

159-
if overwrite_staging {
160-
put_staging_metadata(&metadata)?;
161-
}
162-
163159
if overwrite_remote {
164160
put_remote_metadata(&metadata).await?;
165161
}
166162

163+
if overwrite_staging {
164+
put_staging_metadata(&metadata)?;
165+
}
166+
167167
Ok(metadata)
168168
}
169169

0 commit comments

Comments
 (0)