getsops / getsops/sops

Error unmarshalling file when .env file contains if/else/fi

Open
#1,161 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/stores not-a-bug stores/dotenv
Dominant language
Go
Stars
23.1k
Forks
1.1k
Avg merge
1d 11h
Merged PRs (30d)
9

Description

I am receiving

Error unmarshalling file: invalid dotenv input line: else

when I try to encrypt a *.env file that contacts if/else/fi in it. here's a reproducible .env file:

if [[ "$variable" == 'true' ]]; then
  KEY=value1
else
  KEY=value2
fi
KEY=value3

This is a valid .env file, but SOPS doesn't want to cooperate with it. I am running:

$ sops -v
sops 3.7.3 (latest)

Contributor guide

Open the contributing guide

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

Reproduce the failure with the provided conditional .env content, then locate the dotenv unmarshalling entry point in SOPS. Add regression coverage for if/else/fi syntax and verify encryption succeeds without the invalid-line error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, security
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.