Skip to content

Bug: Error: 'float' object has no attribute 'startswith' when sam local start-api #5475

@arturzangiev

Description

@arturzangiev

Error: 'float' object has no attribute 'startswith' when sam local start-api

Steps to reproduce:

sam local start-api

Observed result:

2023-07-10 21:08:49,434 | Config file location: /Users/arturzangiev/Projects/betting-frontend-api/samconfig.toml                         
2023-07-10 21:08:49,436 | Config file '/Users/arturzangiev/Projects/betting-frontend-api/samconfig.toml' does not exist                  
2023-07-10 21:08:49,448 | Using SAM Template at /Users/arturzangiev/Projects/betting-frontend-api/.aws-sam/build/template.yaml           
2023-07-10 21:08:49,489 | Using config file: samconfig.toml, config environment: default                                                 
2023-07-10 21:08:49,489 | Expand command line arguments to:                                                                              
2023-07-10 21:08:49,490 | --template_file=/Users/arturzangiev/Projects/betting-frontend-api/.aws-sam/build/template.yaml --host=127.0.0.1
--port=3000 --static_dir=public --layer_cache_basedir=/Users/arturzangiev/.aws-sam/layers-pkg --container_host=localhost                 
--container_host_interface=127.0.0.1                                                                                                     
2023-07-10 21:08:49,546 | local start-api command is called                                                                              
2023-07-10 21:08:49,556 | No Parameters detected in the template                                                                         
2023-07-10 21:08:49,570 | There is no customer defined id or cdk path defined for resource ApiGatewayApi, so we will use the resource    
logical id as the resource id                                                                                                            
2023-07-10 21:08:49,571 | Sam customer defined id is more priority than other IDs. Customer defined id for resource                      
bettingFrontendAPIService is bettingFrontendAPIService                                                                                   
2023-07-10 21:08:49,572 | 0 stacks found in the template                                                                                 
2023-07-10 21:08:49,572 | No Parameters detected in the template                                                                         
2023-07-10 21:08:49,583 | There is no customer defined id or cdk path defined for resource ApiGatewayApi, so we will use the resource    
logical id as the resource id                                                                                                            
2023-07-10 21:08:49,583 | Sam customer defined id is more priority than other IDs. Customer defined id for resource                      
bettingFrontendAPIService is bettingFrontendAPIService                                                                                   
2023-07-10 21:08:49,584 | 2 resources found in the stack                                                                                 
2023-07-10 21:08:49,584 | Found Serverless function with name='bettingFrontendAPIService' and CodeUri='bettingFrontendAPIService'        
2023-07-10 21:08:49,585 | --base-dir is not presented, adjusting uri bettingFrontendAPIService relative to                               
/Users/arturzangiev/Projects/betting-frontend-api/.aws-sam/build/template.yaml                                                           
2023-07-10 21:08:49,742 | Detected Inline Swagger definition                                                                             
2023-07-10 21:08:49,743 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics     
2023-07-10 21:08:49,797 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': '9b5b5128-9f22-47b2-af60-dc5f306d0813',           
'installationId': 'ab737077-db0a-4aee-8984-a3e25cfd1ac4', 'sessionId': '6e6221f2-2190-4acc-952b-e5c51f0b100f', 'executionEnvironment':   
'CLI', 'ci': False, 'pyversion': '3.9.13', 'samcliVersion': '1.90.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region':  
'', 'commandName': 'sam local start-api', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName':           
'763061aa365bd0632ed09d4302613f7b61653a69c1a669de39de5c81db3e8524', 'initialCommit': None}, 'duration': 254, 'exitReason':               
'AttributeError', 'exitCode': 255}}]}                                                                                                    
2023-07-10 21:08:50,349 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out.  
(read timeout=0.1)                                                                                                                       

Error: 'float' object has no attribute 'startswith'
Traceback:
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/click/decorators.py", line 93, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/telemetry/metric.py", line 184, in wrapped
    raise exception  # pylint: disable=raising-bad-type
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/telemetry/metric.py", line 149, in wrapped
    return_value = func(*args, **kwargs)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
    actual_result = func(*args, **kwargs)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/cli/main.py", line 95, in wrapper
    return func(*args, **kwargs)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/commands/local/start_api/cli.py", line 118, in cli
    do_cli(
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/commands/local/start_api/cli.py", line 224, in do_cli
    service = LocalApiService(lambda_invoke_context=invoke_context, port=port, host=host, static_dir=static_dir)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/commands/local/lib/local_api_service.py", line 37, in __init__
    self.api_provider = ApiProvider(lambda_invoke_context.stacks, cwd=self.cwd)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/providers/api_provider.py", line 37, in __init__
    self.api = self._extract_api()
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/providers/api_provider.py", line 64, in _extract_api
    provider.extract_resources(self.stacks, collector, cwd=self.cwd)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/providers/sam_api_provider.py", line 72, in extract_resources
    self._extract_from_serverless_api(stack.stack_path, logical_id, resource, collector, cwd=cwd)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/providers/sam_api_provider.py", line 117, in _extract_from_serverless_api
    CfnBaseApiProvider.extract_swagger_route(stack_path, logical_id, body, uri, binary_media, collector, cwd=cwd)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/lib/providers/cfn_base_api_provider.py", line 84, in extract_swagger_route
    authorizers = parser.get_authorizers(event_type)
  File "/Users/arturzangiev/Projects/betting-frontend-api/venv/lib/python3.9/site-packages/samcli/commands/local/lib/swagger/parser.py", line 86, in get_authorizers
    if document_version.startswith(SwaggerParser._2_X_VERSION):

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

Mac
Docker Desktop 4.21.1 (114176)
SAM CLI, version 1.90.0
Python 3.9
eu-west-1

{
  "version": "1.90.0",
  "system": {
    "python": "3.9.13",
    "os": "macOS-13.4.1-arm64-arm-64bit"
  },
  "additional_dependencies": {
    "docker_engine": "24.0.2",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "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"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions