Log information about the event when sending invoking a Lambda via "sls invoke"
See original GitHub issueThis is a Feature Proposal
Description
Over the last couple months a sometimes ran into the issue of sending a string to instead of a JSON object when running sls invoke
. I believe we can improve DX by informing people what actually gets sent.
Current Issue
sls invoke --log -s dev -f updateDesc --data '{ "id": "abc", "description": "test" }'
-> Data is a JSON
In the case above the a JSON ist dedected and converted by sls invoke
.
sls invoke --log -s dev -f updateDesc --data '{ "id": "abc", description: "test" }'
-> Data is a String
In the case above it’s not valid JSON, because the description key doesn’t have quotes. In this case the whole thing is sent as string.
Suggestion we improve the CLI experience by doing the following:
sls invoke --log -s dev -f updateDesc --data '{ "id": "abc", "description": "test" }'
Serverless Request:
{ "id": "abc", "description": "test" }
Serverless Response:
{
"id": "abc",
"name": "test-name"
"description": "test"
}
sls invoke --log -s dev -f updateDesc --data '{ "id": "abc", description: "test" }'
Serverless Request:
'{ "id": "abc", "description": "test" }'
Hint: The data you sent is a String. If you want to send an object all keys must have quotes.
Serverless Response:
{
"id": "abc",
"name": "test-name"
"description": "test"
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Serverless Framework Commands - AWS Lambda - Invoke
Invokes a deployed function. You can send event data, read logs and display other important information of the function invocation.
Read more >Invoking Lambda functions locally - AWS Documentation
You can invoke your AWS Lambda function locally by using the sam local invoke AWS SAM CLI command and providing the function's logical...
Read more >aws lambda - How to pass parameters to serverless invoke local
I am using serverless invoke local -f {function_name} command to test the API calls that does not request any path or query parameters....
Read more >Calling an AWS Lambda function from another Lambda function
In order to test the ChildFunction, you need to create the Test Event, in which you can pass the payload information that we...
Read more >Invoke Lambda Functions Locally - SST.Dev
After you finish creating a Lambda function, you want to first run it locally. Invoking Lambda locally. Let's take the get function defined...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hmm, something seems off about all of this. JSON is a string… so it seems like there is either a bug somewhere or our treatment of the data parameter is a little off… will have to investigate it a bit further to understand what’s going on in that command.
That being said, I like the output with headers. The hints are kind of nice but I think type information should just be part of the output
Closing since this issue is quite old and there are no plans to support this in the foreseeable future.