Skip to content

Commit

Permalink
Fix extension compatibility issues with AWS Lambda Runtime Interface …
Browse files Browse the repository at this point in the history
…Emulator (#879)

* fix: consider status codes 200-299 successful in Extension API

* fix: Make `tracing` JSON field optional
  • Loading branch information
rebu-dt authored May 27, 2024
1 parent b60807e commit ee78eaa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lambda-extension/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::Deserialize;

/// Request tracing information
#[derive(Debug, Deserialize)]
#[derive(Debug, Default, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Tracing {
/// The type of tracing exposed to the extension
Expand All @@ -20,6 +20,7 @@ pub struct InvokeEvent {
/// The function's Amazon Resource Name
pub invoked_function_arn: String,
/// The request tracing information
#[serde(default)]
pub tracing: Tracing,
}

Expand Down
6 changes: 3 additions & 3 deletions lambda-extension/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ where
self.log_port_number,
)?;
let res = client.call(req).await?;
if res.status() != http::StatusCode::OK {
if !res.status().is_success() {
let err = format!("unable to initialize the logs api: {}", res.status());
return Err(ExtensionError::boxed(err));
}
Expand Down Expand Up @@ -318,7 +318,7 @@ where
self.telemetry_port_number,
)?;
let res = client.call(req).await?;
if res.status() != http::StatusCode::OK {
if !res.status().is_success() {
let err = format!("unable to initialize the telemetry api: {}", res.status());
return Err(ExtensionError::boxed(err));
}
Expand Down Expand Up @@ -491,7 +491,7 @@ async fn register<'a>(

let req = requests::register_request(&name, events)?;
let res = client.call(req).await?;
if res.status() != http::StatusCode::OK {
if !res.status().is_success() {
let err = format!("unable to register the extension: {}", res.status());
return Err(ExtensionError::boxed(err));
}
Expand Down

0 comments on commit ee78eaa

Please sign in to comment.