Skip to content

Commit

Permalink
fix(filemanager): make object parsing less strict to avoid errors in …
Browse files Browse the repository at this point in the history
…Lambda function
  • Loading branch information
mmalenic committed Dec 20, 2023
1 parent ff9dbb0 commit 205adb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ impl CollecterBuilder {
trace!(message = ?message, "got the message");

if let Some(body) = message.body() {
serde_json::from_str(body).map_err(|err| DeserializeError(err.to_string()))
let events: Option<FlatS3EventMessages> = serde_json::from_str(body)
.map_err(|err| DeserializeError(err.to_string()))?;
Ok(events.unwrap_or_default())
} else {
Err(SQSReceiveError("No body in SQS message".to_string()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ pub async fn ingest_event(
.into_iter()
.filter_map(|event| {
event.body.map(|body| {
let body: FlatS3EventMessages = serde_json::from_str(&body)?;
Ok(body)
let body: Option<FlatS3EventMessages> = serde_json::from_str(&body)?;
Ok(body.unwrap_or_default())
})
})
.collect::<Result<Vec<FlatS3EventMessages>, Error>>()?
Expand Down

0 comments on commit 205adb1

Please sign in to comment.