PyJWT Error, Screwing With My AWS-SAM-CLI Testing

25 Views Asked by At

Relative AWS Newb and Intermediate Py user, really frustrated by some issues I haven't been able to work through with my good friend, GPT 4.

Basically, I'm trying to do some local integration testing with AWS-SAM-CLI and I keep getting the same error:

**Invoking Lambda_Authorizer.lambda_handler (python3.12)                          
Local image is up-to-date                                                       
Using local image: public.ecr.aws/lambda/python:3.12-rapid-x86_64.              
                                                                                
**Mounting                                                                        
/Users/myusername/Documents/GitHub/myprog/.aws-sam
/build/LambdaAuthorizerFunction as /var/task:ro,delegated, inside runtime       
container                                                                       
START RequestId: 18d1b84f-0b3f-4b37-84ef-63f83507e31a Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'Lambda_Authorizer': cannot import name 'RSAAlgorithm' from 'jwt.algorithms' (/var/task/jwt/algorithms.py)
Traceback (most recent call last):
END RequestId: 39fc51c6-2083-48e9-acfb-93ebae57680f
REPORT RequestId: 39fc51c6-2083-48e9-acfb-93ebae57680f  Init Duration: 0.38 ms  Duration: 745.10 ms Billed Duration: 746 ms Memory Size: 128 MB Max Memory Used: 128 MB 
{"errorMessage": "Unable to import module 'Lambda_Authorizer': cannot import name 'RSAAlgorithm' from 'jwt.algorithms' (/var/task/jwt/algorithms.py)", "errorType": "Runtime.ImportModuleError", "requestId": "39fc51c6-2083-48e9-acfb-93ebae57680f", "stackTrace": []}**

I feel like I've tried everything--I've switched from Py 3.11 to 3.9 to 3.12, using PyEnv/Pycharm, updating my venvs and interpreters every time.

I've checked to see if I could find errant instances of jwt anywhere, and couldn't find them. I have no idea how to get myself out of this.

FYI--the source code I've developed otherwise works, but I can't get this part of it configured.

I've tried to do pretty much everything that GPT suggested:

  1. find / -name '*jwt*' 2>/dev/null - to try to find any conflicting instances of jwt -- it said i have none
  2. cleaning up aws-sam tons of times and rebuilding it only to have it fail when i run this command -- sam local invoke "LambdaAuthorizerFunction" -e event.json
  3. uninstalling and reinstalling python, etc.

It's now suggesting that I use something different like Authlib or python-jose.

I've done pretty much everything I could and now I feel like I'm just plumb out of options. HELP!

0

There are 0 best solutions below