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

provider_meta typo crashes in terraform init #35835

Closed
romanini-ciandt opened this issue Oct 10, 2024 · 2 comments · Fixed by #35842
Closed

provider_meta typo crashes in terraform init #35835

romanini-ciandt opened this issue Oct 10, 2024 · 2 comments · Fixed by #35842
Assignees
Labels
bug confirmed a Terraform Core team member has reproduced this issue new new issue not yet triaged

Comments

@romanini-ciandt
Copy link

romanini-ciandt commented Oct 10, 2024

Terraform Version

Terraform v1.9.1

Terraform Configuration Files

terraform {
  required_version = ">= 1.5.7"

  # Intentional typo below to force a crash. The correct would be "google-beta" instead.
  provider_meta "google_beta" { # 
    hello = "world"
  }
}

Debug Output

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

panic: must contain only letters, digits, and dashes, and may not use leading or trailing dashes
goroutine 1 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x5e
github.com/hashicorp/terraform/internal/logging.PanicHandler()
        github.com/hashicorp/terraform/internal/logging/panic.go:84 +0x18b
panic({0x2e73cc0?, 0xc0003e07d0?})
        runtime/panic.go:770 +0x132
github.com/hashicorp/terraform/internal/addrs.MustParseProviderPart({0xc00074a170?, 0xc0008ca6e8?})
        github.com/hashicorp/terraform/internal/addrs/provider.go:193 +0x45
github.com/hashicorp/terraform/internal/addrs.NewDefaultProvider(...)
        github.com/hashicorp/terraform/internal/addrs/provider.go:89
github.com/hashicorp/terraform/internal/addrs.ImpliedProviderForUnqualifiedType({0xc00074a170?, 0x7bbf85a79ef8?})
        github.com/hashicorp/terraform/internal/addrs/provider.go:81 +0x10e
github.com/hashicorp/terraform/internal/configs.(*Module).ImpliedProviderForUnqualifiedType(...)
        github.com/hashicorp/terraform/internal/configs/module.go:694
github.com/hashicorp/terraform/internal/configs.(*Module).ProviderForLocalConfig(0x0?, {{0xc00074a170?, 0x200025?}, {0x0?, 0x314ab00?}})
        github.com/hashicorp/terraform/internal/configs/module.go:680 +0xaf
github.com/hashicorp/terraform/internal/configs.(*Module).appendFile(0xc0005c2000, 0xc0007681a0)
        github.com/hashicorp/terraform/internal/configs/module.go:269 +0xda8
github.com/hashicorp/terraform/internal/configs.NewModule({0xc000133db0, 0x1, 0x1?}, {0x0, 0x0, 0x1?})
        github.com/hashicorp/terraform/internal/configs/module.go:169 +0x4d5
github.com/hashicorp/terraform/internal/configs.NewModuleWithTests(...)
        github.com/hashicorp/terraform/internal/configs/module.go:102
github.com/hashicorp/terraform/internal/configs.(*Parser).LoadConfigDirWithTests(0xc000a150c0, {0x3dc2468, 0x1}, {0x3524347?, 0x0?})
        github.com/hashicorp/terraform/internal/configs/parser_config_dir.go:73 +0x39b
github.com/hashicorp/terraform/internal/command.(*Meta).loadSingleModuleWithTests(0xc0006828c0, {0xc000082004?, 0xc00042ba70?}, {0x3524347, 0x5})
        github.com/hashicorp/terraform/internal/command/meta_config.go:108 +0xac
github.com/hashicorp/terraform/internal/command.(*InitCommand).Run(0xc0006828c0, {0xc000118030?, 0x0?, 0x0?})
        github.com/hashicorp/terraform/internal/command/init.go:163 +0xe7e
github.com/hashicorp/cli.(*CLI).Run(0xc0003ec280)
        github.com/hashicorp/[email protected]/cli.go:265 +0x5b8
main.realMain()
        github.com/hashicorp/terraform/main.go:339 +0x1e6b
main.main()
        github.com/hashicorp/terraform/main.go:64 +0x13

Expected Behavior

I would expect a handled error message or a successful run when I run terraform init and the configuration files has a provider_meta with an underline (_), or a dot (.) within a string.

Actual Behavior

Currently, if you update the above's code to provider_meta "google-beta-typooooooo" and run a terraform init, it will return Terraform has been successfully initialized!. A successful run.

But a simple typo, provider_meta "google_beta" instead of provider_meta "google-beta" will cause a terraform crash error, and it won't be clear to users why this crash is happening. In a large codebase it can be hard to figure it out why this crash is happening.

Steps to Reproduce

  1. terraform init

Additional Context

No response

References

No response

@romanini-ciandt romanini-ciandt added bug new new issue not yet triaged labels Oct 10, 2024
@crw
Copy link
Collaborator

crw commented Oct 10, 2024

Thanks for this report!

Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue new new issue not yet triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants