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.

Validation fails on uneven indentation

See original GitHub issue

Running on this template - https://github.com/awslabs/serverless-application-model/blob/master/examples/2016-10-31/inline_swagger/template.yaml, sam validate command panics at line-numbers.go

2017/08/11 12:08:53 0.1.0
2017/08/11 12:08:53 PANIC: YAML contains malformed structures
panic: PANIC: YAML contains malformed structures

goroutine 1 [running]:
log.Panicf(0x168d237, 0x29, 0x0, 0x0, 0x0)
	/home/ubuntu/bin/go/src/log/log.go:329 +0xda
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources.ProcessLineNumbers(0xc420597000, 0x48b, 0xe00, 0x168c1c0, 0x27)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/resources/line-numbers.go:116 +0xe8f
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.unmarshal(0xc420597000, 0x48b, 0xe00, 0x1680cef, 0x16, 0x0, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/unmarshal.go:45 +0x403
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.Parse(0xc420597000, 0x48b, 0xe00, 0x48b, 0xe00, 0x0, 0x0, 0xc4204c8028, 0x0)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:49 +0xfe
github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation.read(0x1966360, 0xc4204c8028, 0xc4204c8028, 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(0xc42007e467, 0xd, 0xc42007e467, 0xd, 0x13, 0x0, 0x0, 0xc420220f90)
	/home/ubuntu/repo/src/github.com/awslabs/aws-sam-local/vendor/github.com/awslabs/goformation/goformation.go:29 +0x27e
main.validate(0xc4203ce780)
	/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, 0xc4203ce780, 0xc4204b8a00, 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(0xc420154680, 0xc42000a1e0, 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

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
MCLDG-zzcommented, Aug 15, 2017

I’m having a similar problem using a SAM template that I’ve been using for months. Based on the error message its difficult to know where to start looking for the problem. I’d also suggest that if a template is readily accepted by ‘aws cloudformation package’, it should probably be accepted by SAM local:

sam validate --template sam-airmile-with-stack-dependency.yml 2017/08/15 10:05:47 0.1.0 ERROR: Failed to read the resources line numbers. This usually means that the template contains invalid indentation. Please check it and try again

btw, if I pass the yaml file through http://www.yamllint.com/, it tells me the yaml is valid and reformats it; SAM local is happy with the reformatted output.

0reactions
sanathkrcommented, Aug 20, 2017

Fixed in v0.2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validating Indentation within YAML file - python - Stack Overflow
I am trying to write Python code that checks if indentation within a YAML file is indented correctly and flags an error ......
Read more >
Indentation Error in Python: Causes, How to Solve, Benefits
Select your code and press Tab or Shift + Tab to indent or un-indent it. Other tools for altering your code can be...
Read more >
Effect of crystal orientation on indentation-induced residual ...
The simulations showed that plastic anisotropy is responsible for potentially uneven compressive residual stresses after surface mechanical ...
Read more >
Circle.yml allowed syntax inconsistent with documentation
Hi,. Is this a direct copy of your circle.yml file? If so, it looks like many lines are missing the proper indents. As...
Read more >
How can I correct an indentation error in Pycharm? - Quora
Move the cursor to the line that needs correcting either using the cursor keys or using the mouse to move and then click...
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