Skip to content

Conversation

@estolfo
Copy link
Contributor

@estolfo estolfo commented Oct 20, 2021

The Logs API can set either a string or an object value for the log event record field so we need to handle that when unmarshalling the json.

object value:

{
    "time": "2021-10-20T08:13:03.278Z",
    "type": "platform.end",
    "record": {
        "requestId": "61c0fdeb-f013-4f2a-b627-56278f5666b8"
    }
}

string value:

{
    "time": "2021-10-20T08:13:03.278Z",
    "type": "platform.fault",
    "record": "Unknown application error occurred\nFunction<Exception>\n"
}

Resolves #54

@github-actions github-actions bot added the aws-λ-extension AWS Lambda Extension label Oct 20, 2021
@ghost
Copy link

ghost commented Oct 20, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-10-21T07:43:57.407+0000

  • Duration: 6 min 29 sec

  • Commit: 21780c1

Test stats 🧪

Test Results
Failed 0
Passed 66
Skipped 0
Total 66

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@estolfo estolfo changed the title [WIP] Handle both object and string LogEventRecord types in json Unmarshal Handle both object and string LogEventRecord types in json Unmarshal Oct 20, 2021
@estolfo estolfo requested review from astorm and trentm October 20, 2021 13:52
@estolfo estolfo marked this pull request as ready for review October 20, 2021 13:53
Copy link
Contributor

@astorm astorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Does the thing, has tests, looks great.

require (
github.com/google/go-cmp v0.5.6 // indirect
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting the introduction of a new third party dependency. Project seems well represented by GitHub stars and has a number of tutorials written about it. 👍

@@ -1,8 +1,19 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presuming these all come from the inclusion of stretchr/testify 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@estolfo estolfo merged commit 0efcbb5 into main Oct 25, 2021
@estolfo estolfo deleted the estolfo/record-object branch November 15, 2021 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws-λ-extension AWS Lambda Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"cannot unmarshal string into Go struct field LogEvent.record of type logsapi.LogEventRecord" error

3 participants