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

Bug: boto3 causes SyntaxError when building/invoking with python3.11 #7526

Closed
Gmfholley opened this issue Sep 30, 2024 · 4 comments
Closed
Labels
area/build sam build command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced

Comments

@Gmfholley
Copy link

Gmfholley commented Sep 30, 2024

Description:

Demonstrated with Hello World python3.11 template.

If you use sam init and choose the python 3.11 'Hello, World' template

  1. sam build --use container fails with a source code string cannot contain null bytes error. This happens with no changes to Hello World.
  2. sam build and local invoke -e events/event.json succeeds.
  3. import boto3 and sam build and local invoke will now fail with the same syntax error.

python3.12 or python3.10 builds succeed in all three scenarios.

Steps to reproduce:

  1. sam init
  2. Choose Hello World Template
  3. Use python3.11 runtime
  4. cd into new directory
  5. Run sam build --use-container (fails on build step)
    OR
  6. Add 'import boto3' to the hello_world/app.py file.
  7. Run sam build
  8. Run sam local invoke -e events/event.json (fails on invoke step).

Observed result:

  • For sam build --use-container --debug
    output

  • For sam local invoke -e events/event.json --debug
    output

Expected result:

Expected it to build and return what Hello World is supposed to return, what it returns for python3.10 and python3.12.

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac
  2. sam --version:

{
"version": "1.123.0",
"system": {
"python": "3.8.13",
"os": "macOS-14.6.1-x86_64-i386-64bit"
},
"additional_dependencies": {
"docker_engine": "20.10.8",
"aws_cdk": "Not available",
"terraform": "1.5.7"
},
"available_beta_feature_env_vars": [
"SAM_CLI_BETA_FEATURES",
"SAM_CLI_BETA_BUILD_PERFORMANCE",
"SAM_CLI_BETA_TERRAFORM_SUPPORT",
"SAM_CLI_BETA_RUST_CARGO_LAMBDA"
]
}
12. AWS region: us-east-1

@Gmfholley Gmfholley added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Sep 30, 2024
@hawflau
Copy link
Contributor

hawflau commented Oct 3, 2024

Hi @Gmfholley thanks for raising the issue. I tried your steps to reproduce but it worked fine on my Mac. Can you share the requirements.txt for us to investigate? Thanks!

@hawflau hawflau added blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. area/build sam build command stage/bug-repro The issue/bug needs to be reproduced and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Oct 3, 2024
@Gmfholley
Copy link
Author

@hawflau Did either of them reproduce, or just not the second one? I did fail to add that for the second, I imported boto3.

So for exhaustiveness, the requirements.txt for 'Hello World' that failed on the 'build' step was:

requests

and for importing boto3 was:

requests
boto3

@Gmfholley
Copy link
Author

I tested again, and was again able to reproduce the issue. But since you weren't, I decided to completely delete all Docker volumes and data, and that fixed it. Something must have been broken in my container.

I'm sorry for the bug report. Hopefully this can help someone else.

Copy link
Contributor

github-actions bot commented Oct 3, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues 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
area/build sam build command blocked/more-info-needed More info is needed from the requester. If no response in 14 days, it will become stale. stage/bug-repro The issue/bug needs to be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants