Skip to content

Bug: Error from cookiecutter: open() argument 6 must be str or None, not tuple #4055

@abdulazeezoj

Description

@abdulazeezoj

Description:

When trying to create a SAM app template using sam init, it creates a folder with no content in it.

sam-app
├── events
├── hello_world
└── tests

3 directories, 0 files

When I ran sam init --debug it run an error

2022-07-14 02:53:58,674 | Baking a new template with cookiecutter with all parameters
2022-07-14 02:53:58,727 | Error from cookiecutter: open() argument 6 must be str or None, not tuple
2022-07-14 02:53:58,728 | Template is not provided in context, skip adding project type metric

Steps to reproduce:

$ sam init 

Which template source would you like to use?
        1 - AWS Quick Start Templates
        2 - Custom Template Location
Choice: 1

Choose an AWS Quick Start application template
        1 - Hello World Example
        2 - Multi-step workflow
        3 - Serverless API
        4 - Scheduled task
        5 - Standalone function
        6 - Data processing
        7 - Infrastructure event management
        8 - Machine Learning
Template: 1

Use the most popular runtime and package type? (Python and zip) [y/N]: N

Which runtime would you like to use?
        1 - dotnet6
        2 - dotnet5.0
        3 - dotnetcore3.1
        4 - go1.x
        5 - graalvm.java11 (provided.al2)
        6 - graalvm.java17 (provided.al2)
        7 - java11
        8 - java8.al2
        9 - java8
        10 - nodejs16.x
        11 - nodejs14.x
        12 - nodejs12.x
        13 - python3.9
        14 - python3.8
        15 - python3.7
        16 - python3.6
        17 - ruby2.7
        18 - rust (provided.al2)
Runtime: 14

What package type would you like to use?
        1 - Zip
        2 - Image
Package type: 2

Based on your selections, the only dependency manager available is pip.
We will proceed copying the template using pip.

Would you like to enable X-Ray tracing on the function(s) in your application?  [y/N]: N

Project name [sam-app]: sam-app

Observed result:

user/project $ sam init --debug
2022-07-14 02:52:34,113 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-07-14 02:52:34,113 | Using config file: samconfig.toml, config environment: default
2022-07-14 02:52:34,113 | Expand command line arguments to:
2022-07-14 02:52:34,114 | --package_type=Zip --output_dir=. 

You can preselect a particular runtime or package type when using the `sam init` experience.
Call `sam init --help` to learn more.

Which template source would you like to use?
        1 - AWS Quick Start Templates
        2 - Custom Template Location
Choice: 1

Choose an AWS Quick Start application template
        1 - Hello World Example
        2 - Multi-step workflow
        3 - Serverless API
        4 - Scheduled task
        5 - Standalone function
        6 - Data processing
        7 - Infrastructure event management
        8 - Machine Learning
Template: 1

Use the most popular runtime and package type? (Python and zip) [y/N]: N

Which runtime would you like to use?
        1 - dotnet6
        2 - dotnet5.0
        3 - dotnetcore3.1
        4 - go1.x
        5 - graalvm.java11 (provided.al2)
        6 - graalvm.java17 (provided.al2)
        7 - java11
        8 - java8.al2
        9 - java8
        10 - nodejs16.x
        11 - nodejs14.x
        12 - nodejs12.x
        13 - python3.9
        14 - python3.8
        15 - python3.7
        16 - python3.6
        17 - ruby2.7
        18 - rust (provided.al2)
Runtime: 14

What package type would you like to use?
        1 - Zip
        2 - Image
Package type: 2

Based on your selections, the only dependency manager available is pip.
We will proceed copying the template using pip.

Would you like to enable X-Ray tracing on the function(s) in your application?  [y/N]: 

Project name [sam-app]: 
2022-07-14 02:53:35,233 | 
Cloning from https://github.com/aws/aws-sam-cli-app-templates (process may take a moment)
2022-07-14 02:53:58,115 | Removing old repo at /home/user/.aws-sam/aws-sam-cli-app-templates
2022-07-14 02:53:58,225 | Copying from /tmp/tmpgbdazfe3/aws-sam-cli-app-templates to /home/user/.aws-sam/aws-sam-cli-app-templates

    -----------------------
    Generating application:
    -----------------------
    Name: sam-app
    Base Image: amazon/python3.8-base
    Architectures: x86_64
    Dependency Manager: pip
    Output Directory: .

    Next steps can be found in the README file at ./sam-app/README.md
    

    Commands you can use next
    =========================
    [*] Create pipeline: cd sam-app && sam pipeline init --bootstrap
    [*] Validate SAM template: sam validate
    [*] Test Function in the Cloud: sam sync --stack-name {stack-name} --watch
    
2022-07-14 02:53:58,674 | Parameters dict created with input given
2022-07-14 02:53:58,674 | {'template': '/home/user/.aws-sam/aws-sam-cli-app-templates/python3.8-image/cookiecutter-aws-sam-hello-python-lambda-image', 'output_dir': '.', 'no_input': True, 'extra_context': {'project_name': 'sam-app', 'runtime': 'python3.8', 'architectures': {'value': ['x86_64']}}}
2022-07-14 02:53:58,674 | Baking a new template with cookiecutter with all parameters
2022-07-14 02:53:58,727 | Error from cookiecutter: open() argument 6 must be str or None, not tuple
2022-07-14 02:53:58,728 | Template is not provided in context, skip adding project type metric

Expected result:

I expect it to create the sam app template folder with the necessary files present

sam-app
├── README.md
├── __init__.py
├── events
│   └── event.json
├── hello_world
│   ├── Dockerfile
│   ├── __init__.py
│   ├── app.py
│   └── requirements.txt
├── template.yaml
└── tests
    ├── __init__.py
    └── unit
        ├── __init__.py
        └── test_handler.py

4 directories, 11 files

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

  1. OS: WSL Ubuntu 20.04
  2. sam --version: SAM CLI, version 1.53.0
  3. AWS region:

Add --debug flag to command you are running

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions