question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

YAML is not recognized when using !Sub

See original GitHub issue

When trying to use sam-local with the project https://github.com/taimos/serverless-todo-demo it fails with the following error:

ERROR:  did not find expected alphabetic or numeric character (line: 34; col: 0)

Line 34 uses the string substitution for the IAM permission to DynamoDB:

- !Sub arn:aws:dynamodb:${AWS::Region}:${AWS::AccountId}:table/${TodoTable}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
jagu-sayancommented, Mar 6, 2018

I am still getting this error 😕

0reactions
yyolkcommented, Aug 14, 2017

I got pass the initial failure of not being able to parse !Sub by converting a line like:

Prop: !Sub "my-sub-${RefValue}" throws an error: ☯ sam validate -t sam.yaml 2017/08/14 11:12:19 0.1.0 ERROR: Invalid indentation in template (line: 586; col: 0)

to

Prop: !Sub
  - "my-sub-${RefValue}"
  - {}

and got this error:

2017/08/14 11:12:54 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, 0xc42079ad20, 0x167733c, 0x8, 0xc4201d1bd8)
	/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(0xc420286420, 0x196b860, 0xc420139200, 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, 0xc420139200, 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, 0xc420139200, 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, 0xc420132190, 0x196e4e0, 0xc420132190, 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(0xc420350000, 0x4efb, 0x7e00, 0x4efb, 0x7e00, 0x0, 0x0, 0xc4204a2028, 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, 0xc4204a2028, 0xc4204a2028, 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(0x7fff5fbfec40, 0x8, 0x7fff5fbfec40, 0x8, 0x8, 0x0, 0x0, 0xc420316f90)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:29 +0x27e
main.validate(0xc4203ccf00)
	/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, 0xc4203ccf00, 0xc4204a8800, 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(0xc42058e680, 0xc42007a080, 0x4, 0x4, 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
Read more comments on GitHub >

github_iconTop Results From Across the Web

YAML is not recognized when using !Sub · Issue #30 - GitHub
I tried with the project I mentioned above and ran sam local start-api or sam validate and both failed with the given error....
Read more >
include: some .yaml files not recognized - Configuration
Hi everybody,. I just stumbled upon this when I had issues with the neato integration: sometimes¹, some .yaml files in my packages folder ......
Read more >
How to Fix Errors in YAML (.YML) Config Files - Knowledgebase
Open a YAML parser such as: http://yaml-online-parser.appspot.com/ · Paste your . · If the output (on the right side) is red, read through...
Read more >
Perl YAML module does not recognize types of scalars
I wrote that branch and a sub for dealing with hex values for YAML 0.900.0. ... use YAML qw(LoadFile Dump); use Data::Dumper; my...
Read more >
10 YAML tips for people who hate YAML | Enable Sysadmin
Run the file with Python to produce a file called output. yaml file. This output is perfectly valid YAML, although yamllint does issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found