-
Notifications
You must be signed in to change notification settings - Fork 361
Potential bug in the runtime #250
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
Comments
I'll do some more investigation when I get a chance and see if I can reproduce it with a minimal example |
This is the trace output
|
Can you share your trigger configuration? |
Separately could you capture you're trigger's event payload and past it here? You can do that by downgrading to an untyped We've got a unit test harness to make these types of issues easy to reproduce with sample payloads. https://github.com/awslabs/aws-lambda-rust-runtime/tree/master/lambda-http/tests/data |
I've manage to fix the issue I was having. I had changed my code to use the anyhow crate for error's. When I get a chance tonight I'll build a simple repository (if I can reproduce it). I'm probably just doing something really wrong. |
No worries. The more test cases we have the better |
@softprops I tried to reproduce it, but not having any luck. I did run into something else wondering if you could help me? I have the following function, which get's 403 back from github. I don't see any error logs in cloudwatch. I get back a 500 Internal Server Error from api gateway though. This is the function // use anyhow::{Context, Result};
use kv_log_macro as log;
use lambda_http::{
handler,
lambda::{self},
IntoResponse, Request, Response,
};
use serde::{Deserialize, Serialize};
use serde_json::json;
pub type LambdaError = Box<dyn std::error::Error + Send + Sync + 'static>;
#[derive(Deserialize, Serialize, Debug)]
struct User {
login: String,
id: u32,
}
async fn get_users() -> Result<Vec<User>, LambdaError> {
let url = format!(
"https://api.github.com/repos/{owner}/{repo}/stargazers",
owner = "rust-lang-nursery",
repo = "rust-cookbook"
);
log::info!("Sending request", { url: url });
let response: reqwest::Response = reqwest::get(&url).await?; //.expect("Error sending request");
let body = response.text().await?; //.expect("Error reading body");
let users: Vec<User> = serde_json::from_str(&body)?; //.expect("Error deserializing users");
log::info!("{:?}", users);
Ok(users)
}
async fn func(request: Request, _: lambda::Context) -> Result<impl IntoResponse, LambdaError> {
log::info!("Request: {:?}", request);
let users = get_users().await?; //.expect("Error getting users");
let json = json!(users).to_string();
let response = Response::builder().status(200).body(json)?;
//.expect("Error building response");
log::info!("Finished");
return Ok(response);
}
#[tokio::main]
async fn main() -> Result<(), LambdaError> {
json_env_logger::init();
json_env_logger::panic_hook();
lambda::run(handler(func)).await?;
Ok(())
} And what I get in the logs is this:
I was hoping that the error would bubble up to the runtime and the panic would get logged. |
@jakejscott, we have an unfinished PR #244 where the handler errors are logged by the runtime, but it does not compile with the ApiGateway examples. A bit of a catch 22 for you. That PR is on a different branch. You can make a few simple changes to your |
I found the issue!!! It was a copy-paste bug in my CDK code. I had the following code hooking up the SQS event source to wrong lambda. Wrong: scheduleEmail.addEventSource(new SqsEventSource(queue, {
batchSize: 1
})); Right: sendEmailFunction.addEventSource(new SqsEventSource(queue, {
batchSize: 1
})); Which meant after I published an event to the schedule function, it would publish the message to SQS, and then immediately be reinvoked and error. Sorry for this! |
Good to hear. Thanks for reaching out. |
I just noticed a lambda that kept logging errors. I had to delete the lambda to stop it from running.
I'm using the new HTTP API Gateway to invoke the lambda.
This is what was being logged:
Is this a serde error deseralizing into the
LambdaRequest
type here: https://github.com/awslabs/aws-lambda-rust-runtime/blob/master/lambda-http/src/request.rs#L25The text was updated successfully, but these errors were encountered: