Skip to content

Commit ee78eaa

Browse files
authored
Fix extension compatibility issues with AWS Lambda Runtime Interface Emulator (#879)
* fix: consider status codes 200-299 successful in Extension API * fix: Make `tracing` JSON field optional
1 parent b60807e commit ee78eaa

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lambda-extension/src/events.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::Deserialize;
22

33
/// Request tracing information
4-
#[derive(Debug, Deserialize)]
4+
#[derive(Debug, Default, Deserialize)]
55
#[serde(rename_all = "camelCase")]
66
pub struct Tracing {
77
/// The type of tracing exposed to the extension
@@ -20,6 +20,7 @@ pub struct InvokeEvent {
2020
/// The function's Amazon Resource Name
2121
pub invoked_function_arn: String,
2222
/// The request tracing information
23+
#[serde(default)]
2324
pub tracing: Tracing,
2425
}
2526

lambda-extension/src/extension.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ where
272272
self.log_port_number,
273273
)?;
274274
let res = client.call(req).await?;
275-
if res.status() != http::StatusCode::OK {
275+
if !res.status().is_success() {
276276
let err = format!("unable to initialize the logs api: {}", res.status());
277277
return Err(ExtensionError::boxed(err));
278278
}
@@ -318,7 +318,7 @@ where
318318
self.telemetry_port_number,
319319
)?;
320320
let res = client.call(req).await?;
321-
if res.status() != http::StatusCode::OK {
321+
if !res.status().is_success() {
322322
let err = format!("unable to initialize the telemetry api: {}", res.status());
323323
return Err(ExtensionError::boxed(err));
324324
}
@@ -491,7 +491,7 @@ async fn register<'a>(
491491

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

0 commit comments

Comments
 (0)