Skip to content
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

Discussion: Python 3.10 AttributeError: 'dict' object has no attribute 'header_serializer' #2028

Closed
heitorlessa opened this issue Mar 21, 2023 Discussed in #2022 · 8 comments
Assignees
Labels
feature-request feature request help wanted Could use a second pair of eyes/hands

Comments

@heitorlessa
Copy link
Contributor

Discussed in #2022

Originally posted by raulroscode March 17, 2023
Hello, I have updated my runtime python version to 3.10 and I'm getting this error:

AttributeError: 'dict' object has no attribute 'header_serializer'.


cors = <aws_lambda_powertools.event_handler.api_gateway.CORSConfig object at 0x127ec6800>

    def build(self, event: BaseProxyEvent, cors: Optional[CORSConfig] = None) -> Dict[str, Any]:
        """Build the full response dict to be returned by the lambda"""
        self._route(event, cors)
    
        if isinstance(self.response.body, bytes):
            logger.debug("Encoding bytes response with base64")
            self.response.base64_encoded = True
            self.response.body = base64.b64encode(self.response.body).decode()
    
        return {
            "statusCode": self.response.status_code,
            "body": self.response.body,
            "isBase64Encoded": self.response.base64_encoded,
          **event.header_serializer().serialize(headers=self.response.headers, cookies=self.response.cookies),
        }
      AttributeError: 'dict' object has no attribute 'header_serializer'
venv/lib/python3.10/site-packages/aws_lambda_powertools/event_handler/api_gateway.py:252: AttributeError

I think that aws-lambda-powertools only supports until python 3.9. Should it work with python 3.10?. Do you know when it will be available for python 3.10 and/or 3.11?

Thanks.

@heitorlessa heitorlessa added the feature-request feature request label Mar 21, 2023
@heitorlessa
Copy link
Contributor Author

heitorlessa commented Mar 21, 2023

Copying response here


hey @raulroscode, thanks a lot for creating this discussion. I'll transform as an issue and mark as a feature request so we can track it accordingly :)

We haven't tested with 3.10 as it's not yet officially supported as a managed runtime. That said, the error seems slightly misleading as the event isn't a dict, so I wonder if it's failing due to the dict vs Dict.

One thing that would be super helpful is to have a GitHub sample to reproduce it quickly. I'd also appreciate any contribution for any backwards compatible fix to support 3.10 in areas we don't - I haven't fully gone through line by line in the 3.10 changes yet.

@peterschutt IIRC you've been using 3.10 for quite some time using OCI - have you bumped into this?

@heitorlessa heitorlessa added the help wanted Could use a second pair of eyes/hands label Mar 22, 2023
@peterschutt
Copy link
Contributor

@peterschutt IIRC you've been using 3.10 for quite some time using OCI - have you bumped into this?

Can't say that I have @heitorlessa - I tried to follow the code path and hard to see how that event parameter could be anything other than one of your BaseProxyEvent dataclasses, which should have that method defined. A repro would be great.

@raulroscode
Copy link

Thank you @heitorlessa , I don't know if I can help with something, from the user point of view. If you think so please let me know. Regards.

@leandrodamascena leandrodamascena self-assigned this Apr 10, 2023
@leandrodamascena
Copy link
Contributor

Thank you @heitorlessa , I don't know if I can help with something, from the user point of view. If you think so please let me know. Regards.

Hi @raulroscode! Hope things are going well there.
Yes, you can help us reproduce the issue quickly if you give us an example in a Github repository, for example. It could be a simple hello world example, the main point here is to be able to reproduce the exact problem.

Thank you.

@leandrodamascena
Copy link
Contributor

Hello everyone! Lambda added official support to Python 3.10 and Powertools added this support in v2.14.0.

I put this issue on hold so we have time to have an example of how to test this problem, as we did not detect any errors running Powertools on Python 3.10

@raulroscode
Copy link

raulroscode commented Apr 24, 2023

Hello everyone, sorry for the delay and thank you for the update. I was trying to reproduce the problem in a new and simpler project and I didn't can do it, so may be it was any type of problem with other dependency in our project or a weird case. In fact we already have our code in production working with the version 3.10.

Our next step is to go to 3.11, this version of python has great performance improvements and it would be nice if you could also check that powertools library is compatible with python 3.11.

Thanks for your help.

@leandrodamascena
Copy link
Contributor

Hi @raulroscode, thanks for updating this issue!

Powertools doesn't officially support Python version 3.11 and we don't have an ETA. Overall we expect to have Python 3.11 support on the same date as AWS Lambda 3.11 support and there is no official date for this yet. You can check out this thread about AWS Lambda Python 3.11 support.

I'm closing this issue because we consider that the problem was solved. Feel free to reopen if you have any other questions.

Thank you

@github-actions
Copy link
Contributor

⚠️COMMENT VISIBILITY WARNING⚠️

This issue is now closed. Please be mindful that future comments are hard for our team to see.

If you need more assistance, please either tag a team member or open a new issue that references this one.

If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request feature request help wanted Could use a second pair of eyes/hands
Projects
None yet
Development

No branches or pull requests

4 participants