dvsa / dvsa-lambda-starter

A starting pattern for AWS lambda in Typescript
MIT License
5 stars 4 forks source link

Correctly generate correlationId when lambda is invoked without headers #21

Closed sam-artuso closed 4 years ago

sam-artuso commented 4 years ago

Description

I'm proposing this tiny change after deploying the project to my personal AWS account.

I noticed that when testing lambdas from within the AWS console, by default no HTTP headers are sent (of course it is possible to send them with a bit of fiddling in the UI, though). This will make the lambda go 500 Internal Error.

This simple code change will make the logger correctly fall back to the AWS request ID if no headers are sent.

Not a massive issue, and very unlikely to happen in the real world, but I thought it could be useful.

Related issue: none

Type of change

Checklist:

sdh100shaun commented 4 years ago

Ah great @sam-artuso thank you for the contribution. I haven't run this branch yet but notice you have not checked the test box on our pr template - are there any test cases that are affected or needed here?

sam-artuso commented 4 years ago

I'll add a test case as soon as I get the time.

sdh100shaun commented 4 years ago

@sam-artuso did you manage to squeeze a test(s) in?

sam-artuso commented 4 years ago

@sam-artuso did you manage to squeeze a test(s) in?

Done in 7444a71.