Coder Social home page Coder Social logo

Comments (4)

nibblesnbits avatar nibblesnbits commented on September 26, 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

from aws-sam-cli.

lucashuy avatar lucashuy commented on September 26, 2024

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?

from aws-sam-cli.

nibblesnbits avatar nibblesnbits commented on September 26, 2024

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?

from aws-sam-cli.

github-actions avatar github-actions commented on September 26, 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.

from aws-sam-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.