Closed LumaKernel closed 10 months ago
Hi @LumaKernel 👋 Thank you for reporting this and sorry you are running into trouble here. Could you please show us the full workflow configuration that led to this particular error?
There have been some internal discussions previously about removing the Terraform wrapper as the default (leaving this action only responsible for installation and, potentially, another action for running commands in the GitHub Actions context with setting outputs, etc).
Making it default-false at least sounds like an excellent idea - it's hard to discover that it's the cause even simply trying to use terraform output -json | jq
.
Hi there. Is any updates on this?
I've got the same error at GitHub Actions on calling toBeValidTerraform()
with TypeScript.
const tempOutDir = Testing.fullSynth(terraformStack);
console.log(toBeValidTerraform(tempOutDir).message);
console.log(toPlanSuccessfully(tempOutDir).message);
terraform 1.5.7
Node 18.17.1
Expected subject to be a valid terraform stack: SyntaxError: Unexpected token c in JSON at position 1.
Expected subject not to plan successfully
Node 20.6.1 subject to be a valid terraform stack: SyntaxError: Unexpected token 'c', "[command]/h"... is not valid JSON. Expected subject not to plan successfully
2. macOS case (toBeValid issue):
Node 18.17.1 Expected subject to be a valid terraform stack: SyntaxError: Unexpected token c in JSON at position 1. Expected subject to plan successfully: Error: Command failed: terraform plan -input=false -lock=false .
Node 20.6.1 subject to be a valid terraform stack: SyntaxError: Unexpected token 'c', "[command]/U"... is not valid JSON. Expected subject to plan successfully: Error: Command failed: terraform plan -input=false -lock=false .
It works locally macOS Terraform v1.5.7 on darwin_amd64.
This also leads for me to subsequent errors when using the CDK https://github.com/hashicorp/terraform-cdk-action
Was hunting down for hours this problem until I realized that this problem is there. I was able to workaround this problem with terraform_wrapper: false
. I don't need the outputs.
This issue will be fixed in an upcoming v3.0.0
release next week. Please see this comment for more info
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.
Situation
cdktf get
in GitHub ActionsHere is no hint to know when it gets
c
character while it's parsing JSON.I checked
handlers.js:94:49074
and I figured out that the original code is this.https://github.com/hashicorp/terraform-cdk/blob/49a7072948a115ef20ea5ebe62f8d04117de81c9/packages/%40cdktf/provider-generator/lib/get/generator/provider-schema.ts#L309-L313
Then I tried
terraform providers schema -json
in GitHub Actions and get it's wrapping the CLI.Now we get the character
c
is coming from[command]
Solution candidates
I have no right solution for this, but have ideas.
terraform_wrapper: false
terraform
which is not wrapped, and one anotherterraform-wrapped
which is wrappedNO_GHA_TERRAFORM_WRAP=1
, and setting this from CDKTF side to prevent this potential unrecognizable barrier for CDKTF starters.I like third solution. How about that?