diff --git a/lambda-runtime/src/types.rs b/lambda-runtime/src/types.rs index c8579250..160ef9bb 100644 --- a/lambda-runtime/src/types.rs +++ b/lambda-runtime/src/types.rs @@ -128,14 +128,18 @@ impl TryFrom for Context { .to_str()? .parse() .expect("Missing deadline"), - invoked_function_arn: headers["lambda-runtime-invoked-function-arn"] - .to_str() - .expect("Missing arn; this is a bug") - .to_owned(), - xray_trace_id: headers["lambda-runtime-trace-id"] - .to_str() - .expect("Invalid XRayTraceID sent by Lambda; this is a bug") - .to_owned(), + invoked_function_arn: headers + .get("lambda-runtime-invoked-function-arn") + .map(|h| h.to_str().expect("Invalid arn; this is a bug").to_owned()) + .unwrap_or_default(), + xray_trace_id: headers + .get("lambda-runtime-trace-id") + .map(|h| { + h.to_str() + .expect("Invalid XRayTraceID sent by Lambda; this is a bug") + .to_owned() + }) + .unwrap_or_default(), ..Default::default() }; Ok(ctx)