actions: Python project with NO stack config file throws JSON decoding error

What happened?

Running a github actions pipeline for a Python project that does not have (nor need) a stack config file (e.g. Pulumi.dev.yaml) fails with:

Diagnostics:
    pulumi:pulumi:Stack (python-github-actions-test-dev):
      Traceback (most recent call last):
        File "/opt/hostedtoolcache/pulumi/3.46.1/x64/pulumi-language-python-exec", line 81, in <module>
          config_env = pulumi.runtime.get_config_env()
        File "/home/runner/work/githubactions-test/githubactions-test/venv/lib/python3.8/site-packages/pulumi/runtime/config.py", line 59, in get_config_env
          return json.loads(env_config)
        File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
          return _default_decoder.decode(s)
        File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
          obj, end = self.raw_decode(s, idx=_w(s, 0).end())
        File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
          raise JSONDecodeError("Expecting value", s, err.value) from None
      json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
  
      error: an unhandled error occurred: Program exited with non-zero exit code: 1

The code runs fine from my workstation

Steps to reproduce

  • Create the world’s smallest Pulumi project:

(I.e. it has nothing in the __main__.py file.

"""A Python Pulumi program"""
  • Set up a github actions file like this:
name: Pulumi Preview Test
on:
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  preview:
    name: Preview
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - uses: pulumi/actions@v3
        with:
          command: up
          stack-name: dev # When using an individual account, only use stack-name.  
        env:
          PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
  • pulumi stack init dev
  • run pulumi preview on your workstation and see that it succeeds fine without a Pulumi.dev.yaml file
  • Run the github actions without Pulumi.dev.yaml
  • See error given above.
  • Run github actions with Pulumi.dev.yaml and see that it’s fine.

Expected Behavior

Github actions should not fail if no stack config file provided.

Actual Behavior

github actions fails while command line does not

Output of pulumi about

Pulumi about from github runner:

CLI          
Version      3.44.2
Go Version   go1.19.2
Go Compiler  gc

Plugins
NAME    VERSION
python  unknown

Host     
OS       ubuntu
Version  20.04
Arch     x86_64

This project is written in python: executable='/usr/bin/python3' version='3.8.10
'

Dependencies:
NAME           VERSION
pip            22.3.1
pkg_resources  0.0.0
pulumi         3.46.1
setuptools     65.5.1
wheel          0.38.4

Pulumi about from my workstation:

CLI          
Version      3.46.1
Go Version   go1.19.2
Go Compiler  gc

Plugins
NAME    VERSION
python  unknown

Host     
OS       darwin
Version  12.5.1
Arch     x86_64

This project is written in python: executable='/Users/mitch/.pyenv/shims/python3' version='3.9.6
'

Current Stack: dev

TYPE                 URN
pulumi:pulumi:Stack  urn:pulumi:dev::python-github-actions-test::pulumi:pulumi:Stack::python-github-actions-test-dev


Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/MitchGerdisch
User           MitchGerdisch
Organizations  MitchGerdisch, team-ce, upstarts, demo, mitch-onelogin-test

Dependencies:
NAME        VERSION
pip         22.3.1
pulumi      3.46.1
setuptools  65.5.1
wheel       0.38.4

Additional context

I also installed pulumi version 3.44.2 on my workstation and it still behaved correctly. So it appears to be github actions specific.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you’ve opened one already).

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 16 (9 by maintainers)

Most upvoted comments

I ran into this as well and worked around it like this:

      - uses: pulumi/actions@v3
        env:
          PULUMI_CONFIG: '{}'

The string must be JSON loadable.

Just want to note that it fails in github actions with command set to preview as well.

Great thanks for confirming.

@Zaubeerer, does it work if you change your workflow from

-uses: pulumi/actions@v3
+uses: pulumi/actions@v4

?

Changing to v4 indeed works without the PULUMI_CONFIG workaround 💪

@Zaubeerer, does it work if you change your workflow from

-uses: pulumi/actions@v3
+uses: pulumi/actions@v4

?

It looks like we fixed this for node but comments on community slack (and the original report on this issue) is that this is a problem for Python as well.