question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Log information about the event when sending invoking a Lambda via "sls invoke"

See original GitHub issue

This 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:closed
  • Created 6 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
brianneislercommented, May 26, 2017

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

Object {
  a: 123
}

String '{ "a": 123 }'
0reactions
pmuenscommented, Feb 7, 2019

Closing since this issue is quite old and there are no plans to support this in the foreseeable future.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found