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

feat: improve error message for invalid extra atlantis dependencies #367

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bmbferreira
Copy link

@bmbferreira bmbferreira commented Jan 6, 2025

Pull Request

Related Github Issues

Description

This PR aims to improve the error message thrown when there's an invalid extra dependency declared. Since this problem made me lose a couple of minutes last week, I decided that we can show a proper message for when there's an invalid filepath set on the extra_atlantis_dependencies array.

For the example I'm adding on the test cases, the message before this PR was this:

panic: not a string

        runtime/debug.Stack()
                /usr/local/go/src/runtime/debug/stack.go:26 +0x64
        golang.org/x/sync/singleflight.newPanicError({0x103183aa0, 0x103420890})
                /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:44 +0x24
        golang.org/x/sync/singleflight.(*Group).doCall.func2.1()
                /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:193 +0x40
        panic({0x103183aa0?, 0x103420890?})
                /usr/local/go/src/runtime/panic.go:785 +0x124
        github.com/zclconf/go-cty/cty.Value.AsString({{{0x103437198?, 0x14000052dc0?}}, {0x103217240?, 0x140006b9e00?}})
                /Users/brunoferreira/go/pkg/mod/github.com/zclconf/go-cty@v1.13.2/cty/value_ops.go:1387 +0x128
        github.com/transcend-io/terragrunt-atlantis-config/cmd.resolveLocals({{{0x103437198?, 0x140000531c0?}}, {0x103217240?, 0x140006e2420?}})
                /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/parse_locals.go:195 +0x538
        github.com/transcend-io/terragrunt-atlantis-config/cmd.parseLocals({0x14000110f80, 0x76}, 0x14000893b88, 0x0)
                /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/parse_locals.go:129 +0x254
        github.com/transcend-io/terragrunt-atlantis-config/cmd.getDependencies.func1()
                /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/generate.go:165 +0x208
        golang.org/x/sync/singleflight.(*Group).doCall.func2(0x140005cd976, 0x1400088c190, 0x1400088c101?)
                /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:198 +0x58
        golang.org/x/sync/singleflight.(*Group).doCall(0x103219460?, 0x140000cf2c0?, {0x14000110f80?, 0x76?}, 0x103217000?)
                /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:200 +0x74
        golang.org/x/sync/singleflight.(*Group).Do(0x103f28fc0, {0x14000110f80, 0x76}, 0x1400011ea38)
                /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:113 +0x1bc
        github.com/transcend-io/terragrunt-atlantis-config/cmd.getDependencies({0x14000110f80?, 0x76?}, 0x1400011ead8?)
                /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/generate.go:125 +0x50
        github.com/transcend-io/terragrunt-atlantis-config/cmd.createProject({0x14000110f80, 0x76})
                /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/generate.go:328 +0xa4
        github.com/transcend-io/terragrunt-atlantis-config/cmd.main.func1()
                /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/generate.go:737 +0x78
        golang.org/x/sync/errgroup.(*Group).Go.func1()
                /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/errgroup/errgroup.go:75 +0x54
        created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 5
                /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/errgroup/errgroup.go:72 +0x98


goroutine 6 [running]:
golang.org/x/sync/singleflight.(*Group).doCall.func1()
        /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:170 +0x2cc
golang.org/x/sync/singleflight.(*Group).doCall(0x103219460?, 0x140000cf2c0?, {0x14000110f80?, 0x76?}, 0x103217000?)
        /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:205 +0x94
golang.org/x/sync/singleflight.(*Group).Do(0x103f28fc0, {0x14000110f80, 0x76}, 0x1400011ea38)
        /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/singleflight/singleflight.go:113 +0x1bc
github.com/transcend-io/terragrunt-atlantis-config/cmd.getDependencies({0x14000110f80?, 0x76?}, 0x1400011ead8?)
        /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/generate.go:125 +0x50
github.com/transcend-io/terragrunt-atlantis-config/cmd.createProject({0x14000110f80, 0x76})
        /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/generate.go:328 +0xa4
github.com/transcend-io/terragrunt-atlantis-config/cmd.main.func1()
        /Users/brunoferreira/repos/terragrunt-atlantis-config/cmd/generate.go:737 +0x78
golang.org/x/sync/errgroup.(*Group).Go.func1()
        /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/errgroup/errgroup.go:75 +0x54
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 5
        /Users/brunoferreira/go/pkg/mod/golang.org/x/sync@v0.4.0/errgroup/errgroup.go:72 +0x98

And now it's this:

Error: extra_atlantis_dependencies contains non-string value at position 4

This will allow faster troubleshooting for when there's a valid entry on the extra dependency array.

Security Implications

  • [none]

System Availability

  • [none]

@bmbferreira bmbferreira mentioned this pull request Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant