-
Notifications
You must be signed in to change notification settings - Fork 276
Hard to reach terraform_wrapper: false from CDKTF error #338
Copy link
Copy link
Closed
Description
Situation
- Run
cdktf getin GitHub Actions- It's working in local, but show errors like following.
> cdktf get
SyntaxError: Unexpected token c in JSON at position 1
at JSON.parse (<anonymous>)
at /home/runner/work/<REDACTED>/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:94:49074
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async KM (/home/runner/work/<REDACTED>/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:45:1221)
at async c$ (/home/runner/work/<REDACTED>/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:94:48908)
at async _$.generateTypescriptProvider (/home/runner/work/<REDACTED>/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:96:6837)
at async _$.generateTypescript (/home/runner/work/<REDACTED>/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:96:8841)
at async Promise.all (index 3)
at async _$.generate (/home/runner/work/<REDACTED>/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:99:372)
at async qDe (/home/runner/work/<REDACTED>/node_modules/cdktf-cli/bundle/bin/cmds/handlers.js:176:8163)
⠹ downloading and generating modules and providers...
SyntaxError: Unexpected token c in JSON at position 1
npm ERR! Lifecycle script `get` failed with error:
npm ERR! Error: command failed
npm ERR! in workspace: <REDACTED>
npm ERR! at location: /home/runner/work/<REDACTED>Here 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.
providerSchema = JSON.parse(
await exec(terraformBinaryName, ["providers", "schema", "-json"], {
cwd: outdir,
})
) as ProviderSchema;Then I tried terraform providers schema -json in GitHub Actions and get it's wrapping the CLI.
$ terraform providers schema -json
[command]/home/runner/work/_temp/e3701105-a0d4-426d-80e2-575b823dd917/terraform-bin providers schema -json
{"format_version":"1.0"}
::debug::Terraform exited with code 0.
::debug::stdout: {"format_version":"1.0"}%0A
::debug::stderr:
::debug::exitcode: 0
::set-output name=stdout::{"format_version":"1.0"}%0A
::set-output name=stderr::
::set-output name=exitcode::0Now we get the character c is coming from [command]
Solution candidates
I have no right solution for this, but have ideas.
- Defaulting to
terraform_wrapper: false- simple
- Having 2 binaries, one is
terraformwhich is not wrapped, and one anotherterraform-wrappedwhich is wrapped - Make the ability to force disabling wrapping even if wrapped like with environment var like
NO_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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels