GH Actions, tftest.TerraformTestError: Error decoding plan output: Expecting value: line 1 column 2 (char 1)
See original GitHub issueHi, I’ve been unsuccessful in debugging this error. It appears to emanate from the JSON decoder. However, this only occurs when tests are on a GitHub action. Works without error locally.
Stack
if not output:
return self.execute_command('plan', *cmd_args).out
with tempfile.NamedTemporaryFile() as fp:
fp.close()
# for tg we need to specify a temp name that is relative for the output to go into each
# of the .terragrunt-cache, then plan / show would work, otherwise it overwrites each other!
temp_file = fp.name if len(
self._tg_ra()) == 0 else os.path.basename(fp.name)
cmd_args.append('-out={}'.format(temp_file))
self.execute_command('plan', *cmd_args)
result = self.execute_command('show', '-no-color', '-json', temp_file)
try:
return self._plan_formatter(result.out)
except json.JSONDecodeError as e:
> raise TerraformTestError(
'Error decoding plan output: {}'.format(e))
E tftest.TerraformTestError: Error decoding plan output: Expecting value: line 1 column 2 (char 1)
Code
@pytest.fixture(scope='session')
def fixtures_dir():
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'fixtures')
@pytest.fixture(scope='session')
def terraform_binary():
return shutil.which('terraform')
@pytest.fixture
def plan(fixtures_dir, terraform_binary):
tf = tftest.TerraformTest(tfdir=fixtures_dir, binary=terraform_binary, env=envs)
tf.init()
return tf.plan(output=True)
GH Action
terraform-test:
name: Terraform Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.2
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Test with pytest
run: python -m pytest test-module-fsx-lustre-monitoring.py
Issue Analytics
- State:
- Created a year ago
- Comments:11
Top Results From Across the Web
json.decoder.JSONDecodeError: Expecting value: line 1 ...
Bug description Did a fresh pull from git, tried to run this command python parlai/chat_service/services/browser_chat/run.py --config-path ...
Read more >JSONDecodeError: Expecting value: line 1 column 1 (char 0)
The URL I use for the API call works fine in the browser, but gives this error when done through a curl request....
Read more >Automate Terraform with GitHub Actions - HashiCorp Developer
In this tutorial, you will set up a complete GitHub Actions workflow to deploy a publicly accessible web server within a Terraform Cloud...
Read more >Elevate your Terraform Workflow with GitHub Actions
Are you getting started with Terraform GitOps? Here's a practical guide to running Terraform in GitHub Actions.
Read more >How to use 'terraform output' in a GitHub action - NillsF blog
Recently, I was building a GitHub Actions pipeline, and needed to access ... values from the shell directly, and assign them to variables...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Mikael, have a look at this
https://github.com/ludoo/terraform-module-fsx-lustre/runs/8305560078?check_suite_focus=true
That’s great and thanks for circling back! We should add it to the README!