Hi, everyone. I plan to submit a GH issue, but I w...
# atmos
n
Hi, everyone. I plan to submit a GH issue, but I wanted to make sure I'm not crazy. I believe I may have stumbled across a strange bug with a misleading error message. My problem can be reproduced relatively easily. I have a stack:
Copy code
components:
  terraform:
    testme: {}
And then I create a component called "testme" with a single
main.tf
file.
Copy code
locals {
  hiWorld = "hello world"
  ]
}

output "hw" {
  value = local.hiWorld
}
You'll notice the typo in the
main.tf
. It took me quite a while to eventually boil the problem down to this. To be fair, I should have noticed the syntax error sooner, but I figured if the problem was bad Terraform, I'd get an error message stating that. So, I didn't really bother looking at the component's Terraform at first. So, if I run
atmos terraform plan
or even
atmos terraform validate
for this component, I get this:
Copy code
Error

 Error: invalid component

## Explanation

 Could not find the component  testme  in the stack  weird-problem.
 Check that all the context variables are correctly defined in the stack manifests.
 Are the component and stack names correct? Did you forget an import?
If I remove the syntax mistake, the problem completely disappears and everything runs as expected. The only changes I've made to Atmos recently is I added an 'auth' block to our configuration so we could take advantage of those features. Is this a legitimate bug that I should create a GH Issue for or have I overlooked/misunderstood something? I've definitely had Terraform syntax errors before that did not cause this behavior. Are Terraform locals treated differently in Atmos under the hood?
a
@Nick Dunn please create a HJ issue and add the code and description above, we'll review (and fix) it
the syntax error
]
in terraform causes Atmos to throw the error?
n
That at least appears to be the problem, yes.
I'll create a GH issue. The potential cause here surprised me so much that I thought I'd post here first.
e
i think that's the correct behavior, but the error message is wrong/confusing
We should say the terraform component has invalid HCL code
since both atmos and terraform/opentofu would fail anyways
better to fail fast.
If you're comfortable building atmos, maybe give this a shot https://github.com/cloudposse/atmos/pull/1866
👀 1
merged 1
n
This is not my typical Go development machine, so I had to get things set up quick. 😅 This is definitely far more helpful.
Copy code
Error

 Error: failed to load terraform module: Argument or block definition required: An argument or block definition is required here.

## Explanation

 The Terraform component 'hello/world' contains invalid HCL code at REDACTED/components/terraform/hello/world/main.tf:42.

## Hints

 💡 Run 'atmos terraform validate' to see more details:
I know this was a small task, but I appreciate you jumping on it so quickly. You guys are crushing it - been loving this tool for about a year now.
👍 1
❤️ 1
e
Spread the word! 😃
a
@Nick Dunn if the PR works for you and you are good with it, we'll review and merge (will be released in the next release)
👍 1