Skip to content

Update all dependencies and fix examples #959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jul 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/advanced-appconfig-feature-flags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
async-trait = "0.1.68"
lambda_runtime = "0.13"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
async-trait = "0.1.88"
lambda_runtime = { path = "../../lambda-runtime" }
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
thiserror = "1.0"
thiserror = "2.0"
tokio = { version = "1", features = ["macros"] }
4 changes: 2 additions & 2 deletions examples/advanced-appconfig-feature-flags/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ async fn function_handler<T: ConfigurationFetcher + Send + Sync>(

// Use the feature flag
let msg = if config.spanish_response {
format!("{}, in spanish.", quote)
format!("{quote}, in spanish.")
} else {
format!("{}.", quote)
format!("{quote}.")
};

// Return `Response` (it will be serialized to JSON automatically by the runtime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ edition = "2021"

[dependencies]
#aws dependencies
aws-sdk-config = "0.35.0"
aws-sdk-sqs = "0.35.0"
aws_lambda_events = { version = "0.11.1", features = ["sqs"], default-features = false }
aws_lambda_events = { path = "../../../lambda-events", features = ["sqs"], default-features = false }

#lambda runtime
lambda_runtime = { path = "../../../lambda-runtime" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2021"

[dependencies]
serde = { version = "1.0.191", features = ["derive"] }
serde = { version = "1.0.219", features = ["derive"] }
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ env = { "QUEUE_URL" = "https://changeMe" }

[dependencies]
#aws dependencies
aws-config = "0.57.1"
aws-sdk-config = "0.35.0"
aws-sdk-sqs = "0.35.0"
aws-config = { version = "1.8.1", features = ["behavior-version-latest"] }
aws-sdk-sqs = "1.74.0"

#lambda runtime
lambda_runtime = { path = "../../../lambda-runtime" }
serde_json = "1.0.108"
serde_json = "1.0.140"
tokio = { version = "1", features = ["macros"] }

#shared lib
pizza_lib = { path = "../pizza_lib" }
pizza_lib = { path = "../pizza_lib" }
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async fn main() -> Result<(), Error> {
// read the queue url from the environment
let queue_url = std::env::var("QUEUE_URL").expect("could not read QUEUE_URL");
// build the config from environment variables (fed by AWS Lambda)
let config = aws_config::from_env().load().await;
let config = aws_config::load_from_env().await;
// create our SQS Manager
let sqs_manager = SQSManager::new(aws_sdk_sqs::Client::new(&config), queue_url);
let sqs_manager_ref = &sqs_manager;
Expand Down
2 changes: 0 additions & 2 deletions examples/advanced-sqs-partial-batch-failures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ edition = "2021"

[dependencies]
serde = "^1"
serde_derive = "^1"
serde_with = { version = "^2", features = ["json"], optional = true }
serde_json = "^1"
aws_lambda_events = { path = "../../lambda-events" }
lambda_runtime = { path = "../../lambda-runtime" }
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced-sqs-partial-batch-failures/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ where
D: DeserializeOwned,
R: Future<Output = Result<(), Error>>,
{
run(service_fn(|e| batch_handler(|d| f(d), e))).await
run(service_fn(|e| batch_handler(&f, e))).await
}

/// Helper function to lift the user provided `f` function from message to batch of messages.
Expand Down Expand Up @@ -123,7 +123,7 @@ mod test {
}

#[tokio::test]
async fn test() -> () {
async fn test() {
let msg_to_fail: SqsMessageObj<serde_json::Value> = serde_json::from_str(
r#"{
"messageId": "1",
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-cognito-post-confirmation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
aws-config = "1.5.0"
aws-sdk-ses = "1.28.0"
aws-config = { version = "1.8.1", features = ["behavior-version-latest"] }
aws-sdk-ses = "1.77.0"
aws_lambda_events = { path = "../../lambda-events", default-features = false, features = ["cognito"] }

lambda_runtime = { path = "../../lambda-runtime" }
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-error-error-crates-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"
anyhow = "1"
eyre = "0.6.12"
lambda_runtime = { path = "../../lambda-runtime", features = ["anyhow", "eyre", "miette"] }
miette = "7.2.0"
miette = "7.6.0"
serde = "1"
tokio = { version = "1", features = ["macros"] }
2 changes: 1 addition & 1 deletion examples/basic-error-error-crates-integration/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn miette_error() -> miette::Result<()> {

/// Transform an anyhow::Error, eyre::Report, or miette::Report into a lambda_runtime::Diagnostic.
/// It does it by enabling the feature `anyhow`, `eyre` or `miette` in the runtime dependency.
/// Those features enable the implementation of `From<T> for Diagnostic`
/// Those features enable the implementation of `From<T> for Diagnostic`
/// for `anyhow::Error`, `eyre::Report`, and `miette::Report`.
async fn function_handler(event: LambdaEvent<Request>) -> Result<(), Diagnostic> {
match event.payload.error_type {
Expand Down
6 changes: 3 additions & 3 deletions examples/basic-error-handling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[dependencies]
lambda_runtime = { path = "../../lambda-runtime" }
serde = "1.0.136"
serde_json = "1.0.81"
simple-error = "0.2.3"
serde = "1.0.219"
serde_json = "1.0.140"
simple-error = "0.3.1"
tokio = { version = "1", features = ["macros"] }
8 changes: 4 additions & 4 deletions examples/basic-error-handling/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl std::fmt::Display for CustomError {
/// Display the error struct as a JSON string
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let err_as_json = json!(self).to_string();
write!(f, "{}", err_as_json)
write!(f, "{err_as_json}")
}
}

Expand All @@ -66,7 +66,7 @@ pub(crate) async fn func(event: LambdaEvent<Request>) -> Result<Response, Error>
match event.event_type {
EventType::SimpleError => {
// generate a simple text message error using `simple_error` crate
return Err(Box::new(simple_error::SimpleError::new("A simple error as requested!")));
Err(Box::new(simple_error::SimpleError::new("A simple error as requested!")))
}
EventType::CustomError => {
// generate a custom error using our own structure
Expand All @@ -75,7 +75,7 @@ pub(crate) async fn func(event: LambdaEvent<Request>) -> Result<Response, Error>
req_id: ctx.request_id,
msg: "A custom error as requested!".into(),
};
return Err(Box::new(cust_err));
Err(Box::new(cust_err))
}
EventType::ExternalError => {
// try to open a non-existent file to get an error and propagate it with `?`
Expand All @@ -94,7 +94,7 @@ pub(crate) async fn func(event: LambdaEvent<Request>) -> Result<Response, Error>
msg: "OK".into(),
};

return Ok(resp);
Ok(resp)
}
}
}
2 changes: 1 addition & 1 deletion examples/basic-error-thiserror/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ edition = "2021"

lambda_runtime = { path = "../../lambda-runtime" }
serde = "1"
thiserror = "1.0.61"
thiserror = "2.0"
tokio = { version = "1", features = ["macros"] }
3 changes: 1 addition & 2 deletions examples/basic-error-thiserror/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use lambda_runtime::{service_fn, Diagnostic, Error, LambdaEvent};
use serde::Deserialize;
use thiserror;

#[derive(Deserialize)]
struct Request {}
Expand All @@ -21,7 +20,7 @@ impl From<ExecutionError> for Diagnostic {
};
Diagnostic {
error_type: error_type.into(),
error_message: error_message.into(),
error_message,
}
}
}
Expand Down
11 changes: 4 additions & 7 deletions examples/basic-lambda-external-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ version = "0.1.0"
edition = "2021"

[dependencies]
async-channel = "1.8.0"
futures-lite = "1.13.0"
async-channel = "2.5.0"
futures-lite = "2.6.0"
lambda_runtime = { path = "../../lambda-runtime" }
serde = "1.0.163"
tokio = "1.28.2"

[dev-dependencies]
tokio-test = "0.4.2"
serde = "1.0.219"
tokio = "1.46.1"
4 changes: 2 additions & 2 deletions examples/basic-lambda-external-runtime/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn main() -> Result<(), io::Error> {
my_runtime(move || future::block_on(app_runtime_task(lambda_rx.clone(), shutdown_tx.clone())));

// Block the main thread until a shutdown signal is received.
future::block_on(shutdown_rx.recv()).map_err(|err| io::Error::new(io::ErrorKind::Other, format!("{:?}", err)))
future::block_on(shutdown_rx.recv()).map_err(|err| io::Error::other(format!("{err:?}")))
}

pub(crate) async fn my_handler(event: LambdaEvent<Request>) -> Result<Response, Error> {
Expand All @@ -63,7 +63,7 @@ pub(crate) async fn my_handler(event: LambdaEvent<Request>) -> Result<Response,
// prepare the response
let resp = Response {
req_id: event.context.request_id,
msg: format!("Command {} executed.", command),
msg: format!("Command {command} executed."),
};

// return `Response` (it will be serialized to JSON automatically by the runtime)
Expand Down
5 changes: 1 addition & 4 deletions examples/basic-lambda/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ edition = "2021"

[dependencies]
lambda_runtime = { path = "../../lambda-runtime" }
serde = "1.0.136"
serde = "1.0.219"
tokio = { version = "1", features = ["macros"] }

[dev-dependencies]
tokio-test = "0.4.2"
2 changes: 1 addition & 1 deletion examples/basic-lambda/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub(crate) async fn my_handler(event: LambdaEvent<Request>) -> Result<Response,
// prepare the response
let resp = Response {
req_id: event.context.request_id,
msg: format!("Command {} executed.", command),
msg: format!("Command {command} executed."),
};

// return `Response` (it will be serialized to JSON automatically by the runtime)
Expand Down
19 changes: 8 additions & 11 deletions examples/basic-s3-object-lambda-thumbnail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,16 @@ edition = "2021"
# and it will keep the alphabetic ordering for you.

[dependencies]
aws_lambda_events = "0.8.3"
aws_lambda_events = { path = "../../lambda-events" }
lambda_runtime = { path = "../../lambda-runtime" }
serde = "1"
tokio = { version = "1", features = ["macros"] }
aws-config = "0.55.3"
aws-sdk-s3 = "0.28.0"
aws-config = { version = "1.8.1", features = ["behavior-version-latest"] }
aws-sdk-s3 = "1.96.0"
thumbnailer = "0.5.1"
mime = "0.3.16"
async-trait = "0.1.66"
ureq = "2.6.2"
aws-smithy-http = "0.55.3"
webp = "=0.2.1"
mime = "0.3.17"
async-trait = "0.1.88"
ureq = "3.0.12"

[dev-dependencies]
mockall = "0.11.3"
tokio-test = "0.4.2"
serde_json = "1.0.140"
mockall = "0.13.1"
27 changes: 10 additions & 17 deletions examples/basic-s3-object-lambda-thumbnail/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,25 @@ fn get_thumbnail(vec: Vec<u8>, _size: u32) -> Vec<u8> {
mod tests {
use super::*;
use async_trait::async_trait;
use aws_lambda_events::s3::object_lambda::Configuration;
use aws_lambda_events::s3::object_lambda::HeadObjectContext;
use aws_lambda_events::s3::object_lambda::ListObjectsContext;
use aws_lambda_events::s3::object_lambda::ListObjectsV2Context;
use aws_lambda_events::s3::object_lambda::UserIdentity;
use aws_lambda_events::s3::object_lambda::UserRequest;
use aws_lambda_events::serde_json::json;
use aws_lambda_events::s3::object_lambda::{
Configuration, HeadObjectContext, ListObjectsContext, ListObjectsV2Context, UserIdentity, UserRequest,
};
use lambda_runtime::{Context, LambdaEvent};
use mockall::mock;
use s3::GetFile;
use s3::SendFile;
use s3::{GetFile, SendFile};
use serde_json::json;

#[tokio::test]
async fn response_is_good() {
mock! {
FakeS3Client {}

#[async_trait]
impl GetFile for FakeS3Client {
pub fn get_file(&self, url: String) -> Result<Vec<u8>, Box<dyn error::Error>>;
fn get_file(&self, url: String) -> Result<Vec<u8>, Box<dyn error::Error>>;
}
#[async_trait]
impl SendFile for FakeS3Client {
pub async fn send_file(&self, route: String, token: String, vec: Vec<u8>) -> Result<String, Box<dyn error::Error>>;
async fn send_file(&self, route: String, token: String, vec: Vec<u8>) -> Result<String, Box<dyn error::Error>>;
}
}

Expand All @@ -118,9 +113,7 @@ mod tests {
.returning(|_1| Ok("IMAGE".into()));

mock.expect_send_file()
.withf(|r, t, by| {
return r.eq("O_ROUTE") && t.eq("O_TOKEN") && by == "THUMBNAIL".as_bytes();
})
.withf(|r, t, by| r.eq("O_ROUTE") && t.eq("O_TOKEN") && by == "THUMBNAIL".as_bytes())
.returning(|_1, _2, _3| Ok("File sent.".to_string()));

let payload = get_s3_event();
Expand All @@ -133,7 +126,7 @@ mod tests {
}

fn get_s3_event() -> S3ObjectLambdaEvent {
return S3ObjectLambdaEvent {
S3ObjectLambdaEvent {
x_amz_request_id: ("ID".to_string()),
head_object_context: (Some(HeadObjectContext::default())),
list_objects_context: (Some(ListObjectsContext::default())),
Expand All @@ -151,6 +144,6 @@ mod tests {
supporting_access_point_arn: ("SAPRN".to_string()),
payload: (json!(null)),
}),
};
}
}
}
Loading
Loading