-
Notifications
You must be signed in to change notification settings - Fork 571
rename safeMarshal to mustMarshal #326
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #326 +/- ##
==========================================
- Coverage 74.46% 72.23% -2.23%
==========================================
Files 18 18
Lines 834 724 -110
==========================================
- Hits 621 523 -98
+ Misses 150 136 -14
- Partials 63 65 +2
Continue to review full report at Codecov.
|
can you include a test case that exercises this? |
payload, err := json.Marshal(v) | ||
if err != nil { | ||
return []byte(fmt.Sprintf(serializationErrorFormat, err.Error())) | ||
panic("lambda: " + err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I've misunderstood.
json.Marshal(v)
doesn't return any error, because we know *messages.InvokeResponse_Error
can be marshaled.
So, we don't need to treat this case, and just enough to panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Must"-prefix is usually used in Go (e.g. https://golang.org/pkg/regexp/#MustCompile https://golang.org/pkg/html/template/#Must )
I don't think
|
I tried to write an AWS Lambda handler that causes
This problem remains unresolved. |
Issue #, if available:
the
safeMarshal
function might return invalid JSON iferr.Error()
contains special characters of JSON.aws-lambda-go/lambda/invoke_loop.go
Lines 103 to 109 in 55dc88b
Description of changes:
use
json.Marshal
instead offmt.Sprintf
.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.