actions / actions/runner

Empty env vars not being set in container jobs

Open
#3,043 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
6.3k
Forks
1.4k
Avg merge
1d 16h
Merged PRs (30d)
24

Description

Describe the bug
When you set container env vars, if the env var is an empty string, the env var doesn't get set. This is incorrect as for some purposes there is a logical difference between an env var not being set and an env var being set to an empty string.

To Reproduce

jobs:
  test_env_var_bug:
    name: Test Empty Env Var Bug
    runs-on: ubuntu-latest
    container:
      image: node:18
      env:
        FOO_ONE: ""
        FOO_TWO: "I show up!"
    steps:
    - name: TEST
      run: env | grep "FOO"

Console output:
image

Expected behavior
I'd expect that both env vars are set in the env and that when you run env you'd see something like this:=

Console output:

Run env | grep "FOO"
FOO_ONE=
FOO_TWO=I show up!

Runner Version and Platform

'2.311.0'
ubuntu-latest

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the YAML workflow and container image shown in the report, then trace the runner's container-job environment handling. Done means both FOO_ONE and FOO_TWO appear in the container environment, with FOO_ONE retaining an empty value.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, github-actions
Domain
ci-cd, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.