Skip to content

panic: runtime error: Index out of range [-1] #212

@eimantas-gecas-axomic

Description

@eimantas-gecas-axomic
---
version: 1
description: Lint terraform config
type: Terraform12
files:
  - "env/aws/dev/main.tf"
rules:

  - id: root_resource_naming_convention
    message: "Root resource name must end with the region name"
    category: resource
    severity: FAILURE
    assertions:
      - key: __name__
        op: regex
        value: ".*(us_east_1|us_east_2|us_west_1|us_west_2|af_south_1|ap_east_1|ap_south_1|ap_northeast_1|ap_northeast_2|ap_southeast_1|ap_southeast_2|ca_central_1|eu_central_1|eu_west_1|eu_west_2|eu_west_3|eu_south_1|eu_north_1|me_south_1|sa_east_1)$"
config-lint -debug -rules .configlint/root.yml env/aws/dev
Exclude patterns: []
Filenames to scan: [env/aws/dev/backend.tf env/aws/dev/data.tf env/aws/dev/main.tf env/aws/dev/providers.tf env/aws/dev/terragrunt.hcl env/aws/dev/variables.tf env/aws/dev/versions.tf]
panic: runtime error: index out of range [-1]

goroutine 1 [running]:
github.com/stelligent/config-lint/linter/tf12parser.(*Parser).ParseMany(0xc0001e8b68, 0x0, 0x0, 0x0, 0xc0001e8b00, 0x1009de3, 0x1640140, 0x1612c20, 0x108a301)
	/home/runner/work/config-lint/config-lint/linter/tf12parser/parser.go:48 +0x3eb
github.com/stelligent/config-lint/linter.loadHCLv2(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/runner/work/config-lint/config-lint/linter/terraform_v12.go:88 +0x172
github.com/stelligent/config-lint/linter.Terraform12ResourceLoader.LoadMany(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/runner/work/config-lint/config-lint/linter/terraform_v12.go:68 +0x9f
github.com/stelligent/config-lint/linter.FileLinter.Validate(0xc0000fec00, 0x7, 0x8, 0x1923de0, 0xc000209ec0, 0x192b260, 0x1d0b4e8, 0xc000370ea0, 0xb, 0xc0000c1a40, ...)
	/home/runner/work/config-lint/config-lint/linter/file_linter.go:50 +0x1d4
main.applyRules(0xc000364140, 0x1, 0x1, 0xc0000ac040, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, ...)
	/home/runner/work/config-lint/config-lint/cli/app.go:340 +0x555
main.main()
	/home/runner/work/config-lint/config-lint/cli/app.go:157 +0x67e

This only happens if I set the files to a path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions