terraspace
terraspace copied to clipboard
`terraspace plan` fails error `parse error: Unfinished string at EOF at line 1, column xxxx`
Checklist
- [ x ] Upgrade Terraspace: Are you using the latest version of Terraspace? This allows Terraspace to fix issues fast. There's an Upgrading Guide: https://terraspace.cloud/docs/misc/upgrading/
- [ x ] Reproducibility: Are you reporting a bug others will be able to reproduce and not asking a question. If you're unsure or want to ask a question, do so on https://community.boltops.com
- [ kinda-sorta ] Code sample: Have you put together a code sample to reproduce the issue and make it available? Code samples help speed up fixes dramatically. If it's an easily reproducible issue, then code samples are not needed. If you're unsure, please include a code sample.
My Environment
Software | Version |
---|---|
Operating System | ruby:latest container |
Terraform | OpenTofu 1.8.2 |
Terraspace | 2.2.17 |
Ruby | 3.0.0, 3.3.0 |
Expected Behaviour
In my team's CI environment, we have a job that executes tofu init
> terraspace bundle
> terraspace plan $stack -out plan.tfplan
> terraspace show $stack
--plan plan.tfplan --json`. This set of commands has worked correctly for some time.
Current Behavior
Without any changes to the environment (OS, OpenTofu, Terraspace, Ruby all the same, CI environment also unchanged), the terraspace show
command has begun to fail with the exception below. It is worth noting that the column number reported is not the end of the file, but an arbitrary location.
$ terraspace show $PROJECT_STACK --plan plans/${TS_ENV}_${AWS_REGION}_${PROJECT_STACK}.tfplan --json | convert_report > plans/${TS_ENV}_${AWS_REGION}_${PROJECT_STACK}.json
/usr/local/lib/ruby/3.3.0/json/generic_object.rb:2: warning: ostruct was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0.
You can add ostruct to your Gemfile or gemspec to silence this warning.
Building .terraspace-cache/us-east-1/dev/stacks/company-project-3-deploy
Current directory: .terraspace-cache/us-east-1/dev/stacks/company-project-3-deploy
=> tofu show -json plans/dev_us-east-1_company-project-3-deploy.tfplan
/usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:120:in `handle_input': undefined method `strip' for nil (NoMethodError)
logger.stdin_capture(answer.strip)
^^^^^^
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:68:in `block (3 levels) in handle_streams'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:65:in `each'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:65:in `block (2 levels) in handle_streams'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:60:in `each'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:60:in `block in handle_streams'
from /usr/local/lib/ruby/3.3.0/timeout.rb:186:in `block in timeout'
from /usr/local/lib/ruby/3.3.0/timeout.rb:41:in `handle_timeout'
from /usr/local/lib/ruby/3.3.0/timeout.rb:195:in `timeout'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:53:in `handle_streams'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:42:in `block in popen3'
from /usr/local/lib/ruby/3.3.0/open3.rb:540:in `popen_run'
from /usr/local/lib/ruby/3.3.0/open3.rb:235:in `popen3'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:36:in `popen3'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:26:in `shell'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/shell.rb:17:in `run'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/terraform/runner.rb:53:in `block in terraform'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/hooks/builder.rb:25:in `run_hooks'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/hooks/concern.rb:6:in `run_hooks'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/terraform/runner.rb:50:in `terraform'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/terraform/runner.rb:15:in `block in run'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/terraform/runner.rb:97:in `time_took'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/terraform/runner.rb:14:in `run'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/cli/commander.rb:12:in `run'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/cli.rb:206:in `show'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/command.rb:76:in `dispatch'
from /usr/local/bundle/gems/thor-1.3.2/lib/thor/base.rb:584:in `start'
from /usr/local/bundle/gems/terraspace-2.2.17/lib/terraspace/cli/concern.rb:65:in `start'
from /usr/local/bundle/gems/terraspace-2.2.17/exe/terraspace:7:in `<top (required)>'
from /usr/local/bundle/bin/terraspace:25:in `load'
from /usr/local/bundle/bin/terraspace:25:in `<main>'
parse error: Unfinished string at EOF at line 1, column 1310720
Step-by-step reproduction instructions
- I'm unable to include both the terraform code and
.tfplan
file because of company policy. I am able to directly send the.tfplan
to a contributor if needed. - This error started happening in two separate cases after changes were made to the underlying Terraform code.
- Swapping
terraspace show
for the correspondingtofu show
fixes the issue.