Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Handler parameter unmarshalling not working #2

Closed
bfreis opened this issue Jan 15, 2017 · 8 comments
Closed

Handler parameter unmarshalling not working #2

bfreis opened this issue Jan 15, 2017 · 8 comments

Comments

@bfreis
Copy link

bfreis commented Jan 15, 2017

Hi!

I was trying to use the automatic parameter unmarshalling, but it doesn't seem to work.

I'm using the eawsy/aws-lambda-go-event repo for the event objects. Consider the following handler:

func Handle(event *dynamodbstreamsevt.Event, ctx *runtime.Context) (interface{}, error) {
    fmt.Print(event)
    return nil, nil
}

When I deploy and run this lambda function, a few weird symptoms:

  • no CloudWatch Log Group is ever created for the function
  • Lambda times out the execution after 5 min (that's the timeout I configured for the function)

If I simply change event *dynamodbstreamsevt.Event to event json.RawMessage (and, naturally, remove the import of dynamodbstreamsevt), the code runs successfully and prints the byte array.

The event I'm sending through the Lambda dashboard to test the function is a sample DynamoDB Update event.

Any ideas?

Thanks!
Bruno

@bfreis
Copy link
Author

bfreis commented Jan 15, 2017

Ok, some more investigation...

  1. The Lambda function was not writing to the Log Group by my mistake... I had accidentally removed the CloudWatch Logs permission from the function. My bad!

  2. If I change the signature of my function to use the json.RawMessage parameter, and then perform the unmarshalling inside my handler function, with some log statements before the actual call to json.Unmarshal, I can see those log statements, but the function still times out.

Will try some other things and report back...

@bfreis
Copy link
Author

bfreis commented Jan 15, 2017

Some more investigation:

If I unmarshal the exact same JSON data on evt := &dynamodbstreamsevt.Event{} on my laptop running a main function with go run main.go, it works.

The exact same code, on Lambda, blocks forever.

Could this be (another) issue related to the code being deployed as a Go Plugin?

@bfreis
Copy link
Author

bfreis commented Jan 15, 2017

OK, now this is weird.

If I literally copy and paste the types Event, EventRecord, Record, AttributeValue, and Timestamp, from https://github.com/eawsy/aws-lambda-go-event/blob/master/service/lambda/runtime/event/dynamodbstreamsevt/definition.go to main main.go file, and then unmarshal the exact same data into my now "local" types, IT WORKS!

EDIT: it became even more strange. I created a package in my project, ddbevt, and I copied the 4 .go files from aws-lambda-go-event, into my ddbevt package, and then tried to unmarshal. it does work. There seems to be something about the dynamodbstreamsevt package that is breaking something?

@fsenart
Copy link
Contributor

fsenart commented Jan 15, 2017

@bfreis thank you very much for reporting this issue. I confirm that this is a bug and I've tested with go1.8beta2 all things work but with the update to go1.8rc1 the bug appears.
I need more time to investigate the underlying minimal piece of code which produces the bug, so that I can open an issue on golang/go.
I will keep you informed asap.

@fsenart
Copy link
Contributor

fsenart commented Jan 16, 2017

@bfreis here is the issue golang/go#18676. As you can see, the situation is as weird as you've described.

@fsenart
Copy link
Contributor

fsenart commented Jan 17, 2017

@bfreis the issue is like "resolved" as the patch provided by the golang team works.

But I cannot provide a Docker image for now because I have to rebuild the golang std lib from sources and I do not really want to provide a docker image with a custom build of golang. Golang team will integrate the patch in the next rc and I will update the docker image as soon as the rc is released.

Sorry for the inconvenience.

@bfreis
Copy link
Author

bfreis commented Jan 18, 2017

No worries, @fsenart . Thanks for your support! I'm still quite surprised by how weird this issue is! Glad it should be fixed soon in a future Golang release :)

Cheers!

fsenart added a commit that referenced this issue Jan 19, 2017
@fsenart
Copy link
Contributor

fsenart commented Jan 19, 2017

@bfreis issue resolved, have fun (docker pull ...) ;)

EDIT: we've also updated eawsy/aws-lambda-go-event, do not forget go get stuff.

@fsenart fsenart closed this as completed Jan 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants