Skip to content
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

Panic: Interface conversion error for BatchSize in Dynamodb Stream Event #35

Closed
thijs-jung-trv opened this issue Aug 14, 2017 · 4 comments

Comments

@thijs-jung-trv
Copy link

Issue

When validating a template that contains a Dynamodb Stream Event with a BatchSize I get the following error: panic: interface conversion: interface {} is int, not string. The complete stack trace is added below.

Reproduce

The following example yaml file (from AWS examples under Events) gives me the same error:

# template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
  FunctionName:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.handler
      Runtime: nodejs6.10
      Events:
        Stream:
          Type: DynamoDB
          Properties:
            Stream: !GetAtt DynamoDBTable.StreamArn
            BatchSize: 100
            StartingPosition: TRIM_HORIZON 

Run:

$ sam validate

Output:

$ sam validate
2017/08/14 10:37:51 0.1.0
panic: interface conversion: interface {} is int, not string

goroutine 1 [running]:
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.scaffoldEventSourceMap(0x196b820, 0xc4204eb950, 0x1675e2d)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/aws-serverless-function-event-source.go:102 +0x6c6
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*functionTemplate).Scaffold(0xc420116000, 0x196b860, 0xc42029f7e0, 0x0, 0x0, 0xe, 0x168b7c4, 0x26, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/aws-serverless-function.go:160 +0x583
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*awsServerlessFunction).Scaffold(0x19bcdc0, 0x196b860, 0xc42029f7e0, 0x0, 0x0, 0x26, 0x0, 0x0, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/aws-serverless-function.go:80 +0x6a
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*awsServerlessFunction).ClassConstructor(0x19bcdc0, 0x196b860, 0xc42029f7e0, 0x0, 0x0, 0x0, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/aws-serverless-function.go:61 +0x55
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.postProcess(0x196e4e0, 0xc42028a320, 0x196e4e0, 0xc42028a320, 0x0, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/post-process.go:46 +0x533
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.Parse(0xc42039d200, 0x19a, 0x600, 0x19a, 0x600, 0x0, 0x0, 0xc42000c050, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:72 +0x407
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.read(0x1966360, 0xc42000c050, 0xc42000c050, 0x0, 0x0, 0x0, 0x1, 0x1)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:40 +0x105
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.Open(0xc4201b3119, 0xd, 0xc4201b3119, 0xd, 0x13, 0x0, 0x0, 0xc420310f90)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:29 +0x27e
main.validate(0xc420172640)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/validate.go:13 +0x7a
github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli.HandleAction(0x1587e60, 0x169a720, 0xc420172640, 0xc42043c900, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli/app.go:487 +0x7c
github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli.Command.Run(0x1677894, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x16971ee, 0xa7, 0x0, ...)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli/command.go:207 +0xb72
github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli.(*App).Run(0xc42046d040, 0xc42000a280, 0x2, 0x2, 0x0, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/codegangsta/cli/app.go:250 +0x7d0
main.main()
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/main.go:302 +0x1be1

Fix

When I change BatchSize: 100 to BatchSize: '100' the template is found valid.

$ sam validate
2017/08/14 10:38:01 0.1.0
Valid!

Further digging

$ aws cloudformation validate-template doesn't care about whether BatchSize is a string or an integer.
I hope this is enough information, let me know I can supply you with anything else!

@pesama
Copy link
Contributor

pesama commented Aug 14, 2017

Hi Thijs,

Thanks for the detailed report! There's a bug in goformation, that treats event properties always as strings. I'll submit a PR soon.

Thanks!

@pesama pesama self-assigned this Aug 14, 2017
@pesama pesama added this to the 1.0.0 milestone Aug 14, 2017
@thijs-jung-trv
Copy link
Author

Hey Pelayo,

Thanks for the quick reply. Good luck with the fix and keep up the good work!

Cheers!

@PaulMaddox
Copy link
Contributor

We're rewriting some of the library we use for CloudFormation/SAM parsing (github.com/awslabs/goformation) to make it more resilient against issues like this.

I can confirm this bug is fixed in the 0.1.0 branch of goformation, however we've got a bit more work to do before we can start using it in SAM Local. Shouldn't be much longer.

@sanathkr
Copy link
Contributor

Fixed in v0.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants