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
TypeError - req
is required to have headers
property
#3286
Comments
Thanks for the bug report! At a guess, it will be one of these two commits:
Both of those commits added a Here is the release and commit order for those commits:
Given you said the issue is in v3.42.0, I'm guessing this is with API Gateway trigger usage, and that the problem also exists in v3.41.x. TIL I learned that
It will be straightforward to guard on this. Can you confirm that you are using a Lambda function that is triggered via API Gateway or ELB (ALB)? Apparently the
If my guess is correct, as a workaround until we have a fix, you could switch to v3.40.0 or you could add this to the top of your handler function(s): event.headers = event.headers || {} |
I can reproduce if I manually remove the
|
…eaders' If the lambda handler object for an ELB- or API Gateway-triggered Lambda invocation did not have a 'headers' field, then the Lambda instrumentation would crash. I'm not sure how to get an event with no 'headers' field, but we should still be defensive here. Fixes: #3286
@Alastair-Spencer We have merged a fix. I will try to get a release out soon. If you are able, I am still very curious to know how you got an |
Hi @trentm 👋🏻 Thanks for the reply and no worries on the bug report.
Our lambdas are invoked using I'll try and get you some logs on a deployed version which can help 👍🏻 |
Describe the bug
Since 3.42.0 and 3.44.0 a change has been made which now throws lambda runtimes with TypeErrors due to headers being missing utilised from a low level package basic-auth - https://github.com/jshttp/basic-auth/blob/v1.1.0/index.js#L80-L82. Areas around this package haven't been changed for a while so the cause of the issue is not quite clear yet although i'm trawling through changes in v3.42.0...v3.44.1 to try and help diagnose the cause.
Stack trace:
To Reproduce
Steps to reproduce the behavior:
Standard configuration applies from here on as the lambda is wrapped within the lambda handler and utilises environment configuration.
Expected behavior
Environment (please complete the following information)
How are you starting the agent? (please tick one of the boxes)
agent.start()
directly (e.g.require('elastic-apm-node').start(...)
)elastic-apm-node/start
from within the source code-r elastic-apm-node/start
The text was updated successfully, but these errors were encountered: