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: interface {} is map[interface {}]interface {}, not string #60

Closed
TheDeveloper opened this issue Aug 16, 2017 · 2 comments

Comments

@TheDeveloper
Copy link

Issue

When validating a template that contains a 'AWS::Serverless::Function' with a Policies property I get the following error:

2017/08/16 15:08:57 0.1.0
panic: interface conversion: interface {} is map[interface {}]interface {}, not string

goroutine 1 [running]:
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.safeProcessStringArray(0x196b820, 0xc420236cf0, 0x167733c, 0x8, 0xc4204c9048)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/safe-processing.go:46 +0x15f
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*functionTemplate).Scaffold(0xc4201380b0, 0x196b860, 0xc4202a8f20, 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:146 +0x3bf
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.(*awsServerlessFunction).Scaffold(0x19bcdc0, 0x196b860, 0xc4202a8f20, 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, 0xc4202a8f20, 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, 0xc420448a00, 0x196e4e0, 0xc420448a00, 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(0xc420312000, 0xc4e, 0x1e00, 0xc4e, 0x1e00, 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(0xc4202ab02e, 0xd, 0xc4202ab02e, 0xd, 0x13, 0x0, 0x0, 0xc4202dcf90)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:29 +0x27e
main.validate(0xc42041b040)
	/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, 0xc42041b040, 0xc42006ea00, 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(0xc420338820, 0xc42000e240, 0x3, 0x3, 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

Reproduce

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Resources:
  FunctionName:
      Type: 'AWS::Serverless::Function'
      Properties:
        Handler: index.handler
        Runtime: nodejs6.10
        Policies:
          - Effect: Allow
            Action:
              - 'dynamodb:*'
            Resource: '*'

Remove the policies property and sam validate succeeds.

Looks related to #35

@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