-
Notifications
You must be signed in to change notification settings - Fork 403
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
Feature: Request header keys should case-insensitive #3142
Comments
Thanks for opening your first issue here! We'll come back to you as soon as we can. |
Looking at this now. |
Hello @alnemo! Thank you for opening this issue. Yes, you are right, HTTP header names are case-insensitive, according to RFC 2616. We convert the APIGateway event into a BaseProxyEvent and we get the Do you want to send a PR to fix this? It would be amazing to have your contribution here. Let me know if you want to send this PR or I can send it 🚀 |
Seems like the requests library implemented a case insensitive dict for these cases |
I updated the title and labels because this isn't actually a bug, it's more of a feature request. |
Hey @leandrodamascena - do I understand correctly that the expected behavior here would be to always lowercase keys of If the author won't be interested in submitting a PR, I'd love to take a stab at it 🙌 |
@pgrzesik that's correct ^. Later we can decide in an upcoming version whether we want to make the breaking change for API Gateway Rest API payload (only one that uses non-lower case). If we don't hear from @alnemo by Monday, please Piotr, it'd be awesome to have a PR from you on this so we can include in the next release already. |
Hey guys, if needed I’ll gladly help to review or help developing it further |
Certainly appreciate the review @aradyaron :) Future reference: I'm working (as bandwidth permits) on a revamped contributing guide, integrated into our docs. It'll feature a more detailed coding style guide for contributions, reviews, pathways, and before/after conventions that we follow to make this process easier for everyone. Including the biggest part on... how to write good documentation for various IT personas. |
Hi @pgrzesik! Yes, you're right! Forgot to update the issue after my last comment. It will be amazing to merge your code into Powertools. Please let us know if you need any help. |
Hey 👋 As the original author didn't respond, I'll take a stab at implementing a PR for this 🙌 Just to make sure we're on the same page - do you feel like having something similar to Chalice's |
This implementation makes sense to me. I Just want to see what the customer experience is like. Thank you for your prompt response. |
Hey @leandrodamascena - thanks for the question about the customer experience. I looked into the implementation deeper and I think maybe the best way to improve the current situation is not to change the underlying implementation of Using a case-insensitive mapping to hold PS. Sorry for back and forth on this seemingly simple issue, but I want to make sure I won't break anything for existing users 🙌 |
I agree! Thinking from this point of view, I think we can improve our documentation instead of changing the code. Do you have any ideas in mind to change and improve the documentation?
You mean, add this breaking change in the next major release?
No problem man. We love discussing the best solution with our customers. |
Hey @leandrodamascena, I've published a small PR that highlights the option for case-insensitive lookup in docs: https://github.com/aws-powertools/powertools-lambda-python/pull/3183/files
Correct 👍 Or do you feel like the change there has a low risk of breaking users' existing workflows? |
Hello @alnemo! We've updated our documentation to describe that using |
|
Expected Behaviour
By standard HTTP header keys should not be case sensitive, and in many cases get always converted to lowercase automatically.
For example see Requests library, it defines a case-insensitive dictionary to hold the headers:
from requests.structures import CaseInsensitiveDict
Likewise Chalice uses the same structure for the headers in the request.
Current Behaviour
When using AWS Lambda Powertools the request headers are coming in a standard case-sensitive Python dictionary.
As the result of that retrieving the header by key is case-sensitive.
Code snippet
Possible Solution
No response
Steps to Reproduce
In lambda code attempt to retrieve request header capitalized differently than it is on the incoming request.
Powertools for AWS Lambda (Python) version
latest
AWS Lambda function runtime
3.11
Packaging format used
Lambda Layers
Debugging logs
No response
The text was updated successfully, but these errors were encountered: