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: Error: .NET binaries for Lambda function are not correctly installed #6733

Closed
nibblesnbits opened this issue Feb 23, 2024 · 4 comments
Closed
Labels
area/local blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days type/question

Comments

@nibblesnbits
Copy link

Description:

When running a brand new Lambda Annotations project via sam local start-api, the first request logs out Error: .NET binaries for Lambda function are not correctly installed in the /var/task directory of the image when the image was built. The /var/task directory is missing the required .deps.json file., along with a py stacktrace.

Steps to reproduce:

mkdir my-lambda
cd my-lambda
dotnet new install Amazon.Lambda.Templates
dotnet new serverless.Annotations
cd src/my-lambda
sam local start-api --template-file serverless.template --debug
# now hit http://localhost:3000 from a browser

Observed result:

2024-02-22 20:35:40,329 | No config file found in this directory.
2024-02-22 20:35:40,345 | OSError occurred while reading TOML file: [Errno 2] No such file or
directory: 'D:\\The-UnAd\\monov2\\serverless\\lambda-test\\src\\lambda-test\\samconfig.toml'
2024-02-22 20:35:40,345 | Config file location:
D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\samconfig.toml
2024-02-22 20:35:40,345 | Config file
'D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\samconfig.toml' does not exist
2024-02-22 20:35:40,361 | OSError occurred while reading TOML file: [Errno 2] No such file or
directory: 'D:\\The-UnAd\\monov2\\serverless\\lambda-test\\src\\lambda-test\\samconfig.toml'
2024-02-22 20:35:40,361 | Using config file: samconfig.toml, config environment: default
2024-02-22 20:35:40,361 | Expand command line arguments to:
2024-02-22 20:35:40,361 |
--template_file=D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\serverless.template
--host=127.0.0.1 --port=3000 --static_dir=public
--layer_cache_basedir=C:\Users\sgcol\AppData\Roaming\AWS SAM\layers-pkg
--container_host=localhost --container_host_interface=127.0.0.1
2024-02-22 20:35:40,707 | local start-api command is called
2024-02-22 20:35:40,707 | No Parameters detected in the template
2024-02-22 20:35:40,770 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsDefaultGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,770 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsAddGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,770 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsSubtractGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,770 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsMultiplyGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,770 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsDivideGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,770 | There is no customer defined id or cdk path defined for resource
ServerlessHttpApi, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,770 | 0 stacks found in the template
2024-02-22 20:35:40,770 | No Parameters detected in the template
2024-02-22 20:35:40,785 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsDefaultGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,785 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsAddGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,785 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsSubtractGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,785 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsMultiplyGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,801 | There is no customer defined id or cdk path defined for resource
lambdatestFunctionsDivideGenerated, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,801 | There is no customer defined id or cdk path defined for resource
ServerlessHttpApi, so we will use the resource logical id as the resource id
2024-02-22 20:35:40,801 | 6 resources found in the stack
2024-02-22 20:35:40,801 | Found Serverless function with
name='lambdatestFunctionsDefaultGenerated' and CodeUri='.'
2024-02-22 20:35:40,801 | --base-dir is not presented, adjusting uri . relative to
D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\serverless.template
2024-02-22 20:35:40,801 | Found Serverless function with name='lambdatestFunctionsAddGenerated'
and CodeUri='.'
2024-02-22 20:35:40,801 | --base-dir is not presented, adjusting uri . relative to
D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\serverless.template
2024-02-22 20:35:40,801 | Found Serverless function with
name='lambdatestFunctionsSubtractGenerated' and CodeUri='.'
2024-02-22 20:35:40,801 | --base-dir is not presented, adjusting uri . relative to
D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\serverless.template
2024-02-22 20:35:40,801 | Found Serverless function with
name='lambdatestFunctionsMultiplyGenerated' and CodeUri='.'
2024-02-22 20:35:40,801 | --base-dir is not presented, adjusting uri . relative to
D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\serverless.template
2024-02-22 20:35:40,801 | Found Serverless function with
name='lambdatestFunctionsDivideGenerated' and CodeUri='.'
2024-02-22 20:35:40,801 | --base-dir is not presented, adjusting uri . relative to
D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test\serverless.template
2024-02-22 20:35:40,820 | Found '1' API Events in Serverless function with name
'lambdatestFunctionsDefaultGenerated'
2024-02-22 20:35:40,821 | Found '1' API Events in Serverless function with name
'lambdatestFunctionsAddGenerated'
2024-02-22 20:35:40,822 | Found '1' API Events in Serverless function with name
'lambdatestFunctionsSubtractGenerated'
2024-02-22 20:35:40,823 | Found '1' API Events in Serverless function with name
'lambdatestFunctionsMultiplyGenerated'
2024-02-22 20:35:40,824 | Found '1' API Events in Serverless function with name
'lambdatestFunctionsDivideGenerated'
2024-02-22 20:35:40,825 | Detected Inline Swagger definition
2024-02-22 20:35:40,826 | Parsing Swagger document using 3.0 specification
2024-02-22 20:35:40,827 | Found '0' authorizers in resource 'ServerlessHttpApi'
2024-02-22 20:35:40,827 | Lambda function integration not found in Swagger document at
path='/subtract/{x}/{y}' method='get'
2024-02-22 20:35:40,828 | Lambda function integration not found in Swagger document at
path='/add/{x}/{y}' method='get'
2024-02-22 20:35:40,829 | Lambda function integration not found in Swagger document at
path='/divide/{x}/{y}' method='get'
2024-02-22 20:35:40,830 | Lambda function integration not found in Swagger document at
path='/multiply/{x}/{y}' method='get'
2024-02-22 20:35:40,831 | Lambda function integration not found in Swagger document at path='/'
method='get'
2024-02-22 20:35:40,832 | Found '0' APIs in resource 'ServerlessHttpApi'
2024-02-22 20:35:40,832 | authorizer not found or disabled, returning early
2024-02-22 20:35:40,832 | Removed duplicates from '0' Explicit APIs and '5' Implicit APIs to
produce '5' APIs
2024-02-22 20:35:40,832 | 5 APIs found in the template
2024-02-22 20:35:40,843 | Mounting lambdatestFunctionsDivideGenerated at
http://127.0.0.1:3000/divide/{x}/{y} [GET]
2024-02-22 20:35:40,845 | Mounting lambdatestFunctionsMultiplyGenerated at
http://127.0.0.1:3000/multiply/{x}/{y} [GET]
2024-02-22 20:35:40,846 | Mounting lambdatestFunctionsAddGenerated at
http://127.0.0.1:3000/add/{x}/{y} [GET]
2024-02-22 20:35:40,847 | Mounting lambdatestFunctionsDefaultGenerated at
http://127.0.0.1:3000/ [GET]
2024-02-22 20:35:40,848 | Mounting lambdatestFunctionsSubtractGenerated at
http://127.0.0.1:3000/subtract/{x}/{y} [GET]
2024-02-22 20:35:40,849 | You can now browse to the above endpoints to invoke your functions.
You do not need to restart/reload SAM CLI while working on your functions, changes will be
reflected instantly/automatically. If you used sam build before running local commands, you
will need to re-run sam build for the changes to be picked up. You only need to restart SAM CLI
if you update your AWS SAM template
2024-02-22 20:35:40,850 | Localhost server is starting up. Multi-threading = True
2024-02-22 20:35:40,851 | Setting SIGTERM interrupt handler
2024-02-22 20:35:40 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:3000
2024-02-22 20:35:40 Press CTRL+C to quit
2024-02-22 20:35:47,663 | Constructed Event Version 2.0 to invoke Lambda. Event: {'version':
'2.0', 'routeKey': 'GET /', 'rawPath': '/', 'rawQueryString': '', 'cookies': [], 'headers':
{'Host': '127.0.0.1:3000', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0)
Gecko/20100101 Firefox/124.0', 'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate, br', 'Connection':
'keep-alive', 'Upgrade-Insecure-Requests': '1', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode':
'navigate', 'Sec-Fetch-Site': 'none', 'Sec-Fetch-User': '?1', 'X-Forwarded-Proto': 'http',
'X-Forwarded-Port': '3000'}, 'requestContext': {'accountId': '123456789012', 'apiId':
'1234567890', 'http': {'method': 'GET', 'path': '/', 'protocol': 'HTTP/1.1', 'sourceIp':
'127.0.0.1', 'userAgent': 'Custom User Agent String'}, 'requestId':
'bb1c1ee4-1c4b-49c3-ad49-f6e5debce347', 'routeKey': 'GET /', 'stage': '$default', 'time':
'23/Feb/2024:01:35:40 +0000', 'timeEpoch': 1708652140, 'domainName': 'localhost',
'domainPrefix': 'localhost'}, 'body': '', 'pathParameters': {}, 'stageVariables': None,
'isBase64Encoded': False}
2024-02-22 20:35:47,663 | Found one Lambda function with name
'lambdatestFunctionsDefaultGenerated'
2024-02-22 20:35:47,663 | Invoking
lambda-test::lambda_test.Functions_Default_Generated::Default (dotnet8)
2024-02-22 20:35:47,663 | No environment variables found for function
'lambdatestFunctionsDefaultGenerated'
2024-02-22 20:35:47,663 | Loading AWS credentials from session with profile 'None'
2024-02-22 20:35:47,679 | Resolving code path.
Cwd=D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test,
CodeUri=D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test
2024-02-22 20:35:47,679 | Resolved absolute path to code is
D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test
2024-02-22 20:35:47,694 | Code D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test is not
a zip/jar file
2024-02-22 20:35:49,157 | Local image is up-to-date
2024-02-22 20:35:49,165 | Checking free port on 127.0.0.1:8348
2024-02-22 20:35:49,171 | Using local image: public.ecr.aws/lambda/dotnet:8-rapid-x86_64.

2024-02-22 20:35:49,173 | Mounting D:\The-UnAd\monov2\serverless\lambda-test\src\lambda-test as
/var/task:ro,delegated, inside runtime container
2024-02-22 20:35:50,076 | Starting a timer for 30 seconds for function
'lambdatestFunctionsDefaultGenerated'
2024-02-22 20:35:50,079 | Getting lock for the key localhost-8348
2024-02-22 20:35:50,080 | Waiting to retrieve the lock (localhost-8348) to start invocation
START RequestId: 948f6afa-39b2-434b-9134-6a48e591cc5a Version: $LATEST
Error: .NET binaries for Lambda function are not correctly installed in the /var/task directory of the image when the image was built. The /var/task directory is missing the required .deps.json file.
23 Feb 2024 01:35:51,104 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 105 InvokeID=
23 Feb 2024 01:35:51,105 [ERROR] (rapid) Invoke failed error=Runtime exited with error: exit status 105 InvokeID=aa73205b-97fd-4f5d-988a-186780b776e1
23 Feb 2024 01:35:51,105 [ERROR] (rapid) Invoke DONE failed: Sandbox.Failure
2024-02-22 20:35:51,111 | [Container state] OOMKilled False
2024-02-22 20:35:51,468 | Cleaning all decompressed code dirs
2024-02-22 20:35:51,469 | Exception on / [GET]
Traceback (most recent call last):
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\flask\app.py", line 1463,
in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\flask\app.py", line 872, in
full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\flask\app.py", line 870, in
full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\flask\app.py", line 855, in
dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type:
ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program
Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\local\apigw\local_apigw_service.py",
line 724, in _request_handler
    lambda_response = self._invoke_lambda_function(route.function_name, route_lambda_event)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program
Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\local\apigw\local_apigw_service.py",
line 617, in _invoke_lambda_function
    self.lambda_runner.invoke(lambda_function_name, event_str, stdout=stdout_writer,
stderr=self.stderr)
  File "C:\Program
Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\commands\local\lib\local_lambda.py",
line 147, in invoke
    self.local_runtime.invoke(
  File "C:\Program
Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\telemetry\metric.py", line 325, in
wrapped_func
    return_value = func(*args, **kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program
Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\local\lambdafn\runtime.py", line 214,
in invoke
    container.wait_for_result(
  File "C:\Program
Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\local\docker\container.py", line 433,
in wait_for_result
    response, is_image = self.wait_for_http_response(full_path, event, stdout)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\lib\utils\retry.py",
line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program
Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\samcli\local\docker\container.py", line 405,
in wait_for_http_response
    if "image" in resp.headers["Content-Type"]:
                  ~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "C:\Program Files\Amazon\AWSSAMCLI\runtime\Lib\site-packages\requests\structures.py",
line 52, in __getitem__
    return self._store[key.lower()][1]
           ~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'content-type'
2024-02-22 20:35:51,481 | Lambda execution failed (<InternalServerError '500: Internal Server
Error'>,)
2024-02-22 20:35:51 127.0.0.1 - - [22/Feb/2024 20:35:51] "GET / HTTP/1.1" 502 -
2024-02-22 20:35:51 127.0.0.1 - - [22/Feb/2024 20:35:51] "GET /favicon.ico HTTP/1.1" 403 -

Expected result:

200 response

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

  1. OS: Windows 11 Pro 23H2
  2. sam --version: SAM CLI, version 1.110.0
  3. AWS region: us-east-2
{
  "version": "1.110.0",
  "system": {
    "python": "3.11.7",
    "os": "Windows-10-10.0.22631-SP0"
  },
  "additional_dependencies": {
    "docker_engine": "25.0.3",
    "aws_cdk": "Not available",
    "terraform": "1.7.3"
  },
  "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"
  ]
}
@nibblesnbits nibblesnbits added the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Feb 23, 2024
@nibblesnbits
Copy link
Author

nibblesnbits commented Feb 23, 2024

Update: this also happens when using sam init using ANY configuration that uses dotnet8 OR dotnet6.

Running with sam local start-api gives similar errors in both Windows and Ubuntu on WSL2.

sven@sven-omen:~/code/sam-app$ sam local start-api --debug
2024-02-23 00:38:10,524 | Config file location: /home/sven/code/sam-app/samconfig.toml
2024-02-23 00:38:10,527 | Loading configuration values from [default.['local',
'start-api'].parameters] (env.command_name.section) in config file at
'/home/sven/code/sam-app/samconfig.toml'...
2024-02-23 00:38:10,529 | Configuration values successfully loaded.
2024-02-23 00:38:10,530 | Configuration values are: {'stack_name': 'sam-app',
'warm_containers': 'EAGER'}
2024-02-23 00:38:10,534 | Using SAM Template at /home/sven/code/sam-app/template.yaml
2024-02-23 00:38:10,577 | Using config file: samconfig.toml, config environment: default
2024-02-23 00:38:10,578 | Expand command line arguments to:
2024-02-23 00:38:10,579 | --template_file=/home/sven/code/sam-app/template.yaml
--host=127.0.0.1 --port=3000 --static_dir=public
--layer_cache_basedir=/home/sven/.aws-sam/layers-pkg --warm_containers=EAGER
--container_host=localhost --container_host_interface=127.0.0.1
2024-02-23 00:38:10,673 | local start-api command is called
2024-02-23 00:38:10,677 | No Parameters detected in the template
2024-02-23 00:38:10,698 | There is no customer defined id or cdk path defined for resource
HelloWorldFunction, so we will use the resource logical id as the resource id
2024-02-23 00:38:10,699 | There is no customer defined id or cdk path defined for resource
ServerlessRestApi, so we will use the resource logical id as the resource id
2024-02-23 00:38:10,700 | 0 stacks found in the template
2024-02-23 00:38:10,701 | No Parameters detected in the template
2024-02-23 00:38:10,718 | There is no customer defined id or cdk path defined for resource
HelloWorldFunction, so we will use the resource logical id as the resource id
2024-02-23 00:38:10,719 | There is no customer defined id or cdk path defined for resource
ServerlessRestApi, so we will use the resource logical id as the resource id
2024-02-23 00:38:10,720 | 2 resources found in the stack
2024-02-23 00:38:10,721 | Found Serverless function with name='HelloWorldFunction' and
CodeUri='./src/HelloWorld/'
2024-02-23 00:38:10,722 | --base-dir is not presented, adjusting uri ./src/HelloWorld/ relative
to /home/sven/code/sam-app/template.yaml
2024-02-23 00:38:10,723 | watch resource /home/sven/code/sam-app/template.yaml
2024-02-23 00:38:10,724 | Create Observer for resource /home/sven/code/sam-app/template.yaml
with recursive True
2024-02-23 00:38:10,725 | watch resource /home/sven/code/sam-app/template.yaml's parent
/home/sven/code/sam-app
2024-02-23 00:38:10,726 | Create Observer for resource /home/sven/code/sam-app with recursive
False
2024-02-23 00:38:10,735 | Initializing the lambda functions containers.
2024-02-23 00:38:10,736 | Async execution started
2024-02-23 00:38:10,737 | Invoking function functools.partial(<function
InvokeContext._initialize_all_functions_containers.<locals>.initialize_function_container at
0x7fc75e002ca0>, Function(function_id='HelloWorldFunction', name='HelloWorldFunction',
functionname='HelloWorldFunction', runtime='dotnet8', memory=512, timeout=10,
handler='HelloWorld::HelloWorld.Function::FunctionHandler', imageuri=None, packagetype='Zip',
imageconfig=None, codeuri='/home/sven/code/sam-app/src/HelloWorld', environment={'Variables':
{'PARAM1': 'VALUE'}}, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api',
'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}},
metadata={'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None,
architectures=['x86_64'], function_url_config=None,
function_build_info=<FunctionBuildInfo.BuildableZip: ('BuildableZip', 'Regular ZIP function
which can be build with SAM CLI')>, stack_path='', runtime_management_config=None,
logging_config=None))
2024-02-23 00:38:10,742 | Waiting for async results
2024-02-23 00:38:10,747 | Loading AWS credentials from session with profile 'None'
2024-02-23 00:38:10,770 | Resolving code path. Cwd=/home/sven/code/sam-app,
CodeUri=/home/sven/code/sam-app/src/HelloWorld
2024-02-23 00:38:10,771 | Resolved absolute path to code is
/home/sven/code/sam-app/src/HelloWorld
2024-02-23 00:38:10,772 | watch resource /home/sven/code/sam-app/src/HelloWorld
2024-02-23 00:38:10,773 | Create Observer for resource /home/sven/code/sam-app/src/HelloWorld
with recursive True
2024-02-23 00:38:10,775 | watch resource /home/sven/code/sam-app/src/HelloWorld's parent
/home/sven/code/sam-app/src
2024-02-23 00:38:10,776 | Create Observer for resource /home/sven/code/sam-app/src with
recursive False
2024-02-23 00:38:10,778 | Code /home/sven/code/sam-app/src/HelloWorld is not a zip/jar file
2024-02-23 00:38:12,007 | Local image is up-to-date
2024-02-23 00:38:12,017 | Checking free port on 127.0.0.1:6087
2024-02-23 00:38:12,024 | Using local image: public.ecr.aws/lambda/dotnet:8-rapid-x86_64.

2024-02-23 00:38:12,025 | Mounting /home/sven/code/sam-app/src/HelloWorld as
/var/task:ro,delegated, inside runtime container
2024-02-23 00:38:12,376 | Async execution completed
2024-02-23 00:38:12,378 | Containers Initialization is done.
2024-02-23 00:38:12,379 | Found '1' API Events in Serverless function with name
'HelloWorldFunction'
2024-02-23 00:38:12,379 | Detected Inline Swagger definition
2024-02-23 00:38:12,380 | Parsing Swagger document using 2.0 specification
2024-02-23 00:38:12,381 | Found '0' authorizers in resource 'ServerlessRestApi'
2024-02-23 00:38:12,382 | Lambda function integration not found in Swagger document at
path='/hello' method='get'
2024-02-23 00:38:12,383 | Found '0' APIs in resource 'ServerlessRestApi'
2024-02-23 00:38:12,383 | Authorizer not found or disabled, returning early
2024-02-23 00:38:12,385 | Removed duplicates from '0' Explicit APIs and '1' Implicit APIs to
produce '1' APIs
2024-02-23 00:38:12,386 | 1 APIs found in the template
2024-02-23 00:38:12,388 | Mounting HelloWorldFunction at http://127.0.0.1:3000/hello [GET]
2024-02-23 00:38:12,389 | You can now browse to the above endpoints to invoke your functions.
You do not need to restart/reload SAM CLI while working on your functions, changes will be
reflected instantly/automatically. If you used sam build before running local commands, you
will need to re-run sam build for the changes to be picked up. You only need to restart SAM CLI
if you update your AWS SAM template
2024-02-23 00:38:12,390 | Localhost server is starting up. Multi-threading = True
2024-02-23 00:38:12,391 | Setting SIGTERM interrupt handler
2024-02-23 00:38:12 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:3000
2024-02-23 00:38:12 Press CTRL+C to quit
2024-02-23 00:38:17,034 | Constructed Event 1.0 to invoke Lambda. Event: {'httpMethod': 'GET',
'body': None, 'resource': '/hello', 'requestContext': {'resourceId': '123456', 'apiId':
'1234567890', 'resourcePath': '/hello', 'httpMethod': 'GET', 'requestId':
'017d2318-2bff-407b-9fd5-74e90e0582f4', 'accountId': '123456789012', 'stage': 'Prod',
'identity': {'apiKey': None, 'userArn': None, 'cognitoAuthenticationType': None, 'caller':
None, 'userAgent': 'Custom User Agent String', 'user': None, 'cognitoIdentityPoolId': None,
'cognitoAuthenticationProvider': None, 'sourceIp': '127.0.0.1', 'accountId': None},
'extendedRequestId': None, 'path': '/hello', 'protocol': 'HTTP/1.1', 'domainName':
'127.0.0.1:3000', 'requestTimeEpoch': 1708666690, 'requestTime': '23/Feb/2024:05:38:10 +0000'},
'queryStringParameters': None, 'multiValueQueryStringParameters': None, 'headers': {'Host':
'127.0.0.1:3000', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0)
Gecko/20100101 Firefox/124.0', 'Accept':
'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate, br', 'Connection':
'keep-alive', 'Upgrade-Insecure-Requests': '1', 'Sec-Fetch-Dest': 'document', 'Sec-Fetch-Mode':
'navigate', 'Sec-Fetch-Site': 'none', 'Sec-Fetch-User': '?1', 'X-Forwarded-Proto': 'http',
'X-Forwarded-Port': '3000'}, 'multiValueHeaders': {'Host': ['127.0.0.1:3000'], 'User-Agent':
['Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0'], 'Accept':
['text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8'],
'Accept-Language': ['en-US,en;q=0.5'], 'Accept-Encoding': ['gzip, deflate, br'], 'Connection':
['keep-alive'], 'Upgrade-Insecure-Requests': ['1'], 'Sec-Fetch-Dest': ['document'],
'Sec-Fetch-Mode': ['navigate'], 'Sec-Fetch-Site': ['none'], 'Sec-Fetch-User': ['?1'],
'X-Forwarded-Proto': ['http'], 'X-Forwarded-Port': ['3000']}, 'pathParameters': None,
'stageVariables': None, 'path': '/hello', 'isBase64Encoded': False}
2024-02-23 00:38:17,041 | Found one Lambda function with name 'HelloWorldFunction'
2024-02-23 00:38:17,042 | Invoking HelloWorld::HelloWorld.Function::FunctionHandler (dotnet8)
2024-02-23 00:38:17,042 | Resolving code path. Cwd=/home/sven/code/sam-app,
CodeUri=/home/sven/code/sam-app/src/HelloWorld
2024-02-23 00:38:17,043 | Resolved absolute path to code is
/home/sven/code/sam-app/src/HelloWorld
2024-02-23 00:38:17,055 | Reuse the created warm container for Lambda function
'HelloWorldFunction'
2024-02-23 00:38:17,064 | Lambda function 'HelloWorldFunction' is already running
2024-02-23 00:38:17,067 | Starting a timer for 10 seconds for function 'HelloWorldFunction'
2024-02-23 00:38:17,068 | Getting lock for the key localhost-6087
2024-02-23 00:38:17,069 | Waiting to retrieve the lock (localhost-6087) to start invocation
2024-02-23 00:38:17,085 | Exception on /hello [GET]
Traceback (most recent call last):
  File "flask/app.py", line 1463, in wsgi_app
  File "flask/app.py", line 872, in full_dispatch_request
  File "flask/app.py", line 870, in full_dispatch_request
  File "flask/app.py", line 855, in dispatch_request
  File "samcli/local/apigw/local_apigw_service.py", line 724, in _request_handler
  File "samcli/local/apigw/local_apigw_service.py", line 617, in _invoke_lambda_function
  File "samcli/commands/local/lib/local_lambda.py", line 147, in invoke
  File "samcli/lib/telemetry/metric.py", line 325, in wrapped_func
  File "samcli/local/lambdafn/runtime.py", line 214, in invoke
  File "samcli/local/docker/container.py", line 433, in wait_for_result
  File "samcli/lib/utils/retry.py", line 31, in wrapper
  File "samcli/local/docker/container.py", line 405, in wait_for_http_response
  File "requests/structures.py", line 52, in __getitem__
KeyError: 'content-type'
2024-02-23 00:38:17,089 | Lambda execution failed (<InternalServerError '500: Internal Server
Error'>,)
2024-02-23 00:38:17 127.0.0.1 - - [23/Feb/2024 00:38:17] "GET /hello HTTP/1.1" 502 -
START RequestId: ac85acee-bd3e-4b4a-a6c3-fa4cb6d50f3a Version: $LATEST
Error: .NET binaries for Lambda function are not correctly installed in the /var/task directory of the image when the image was built. The /var/task directory is missing the required .deps.json file.
23 Feb 2024 05:38:17,083 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 105 InvokeID=
23 Feb 2024 05:38:17,083 [ERROR] (rapid) Invoke failed error=Runtime exited with error: exit status 105 InvokeID=70566743-a73e-4bcb-aad5-3fc5a16caa49
23 Feb 2024 05:38:17,084 [ERROR] (rapid) Invoke DONE failed: Sandbox.Failure
2024-02-23 00:38:17 127.0.0.1 - - [23/Feb/2024 00:38:17] "GET /favicon.ico HTTP/1.1" 403 -
2024-02-23 00:38:27,069 | Function 'HelloWorldFunction' timed out after 10 seconds

@lucashuy
Copy link
Contributor

Hi, dotnet projects need to be built before being run with our local commands. This can be done with sam build. I can reproduce the error you get on a project that has not been built, can you try building the dotnet8 and dotnet6 projects you used before trying sam local start-api?

@lucashuy lucashuy added type/question blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days area/local and removed stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Feb 23, 2024
@nibblesnbits
Copy link
Author

Looks like that fixes it. Wild.
So I guess this can be closed.
Can you point to the docs that call this out, if you have it off hand?

Copy link
Contributor

⚠️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/local blocked/close-if-inactive Blocked for >14 days with no response, will be closed if still inactive after 7 days type/question
Projects
None yet
Development

No branches or pull requests

2 participants