Dotenv artifact does not accept empty lines ?

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

Dotenv parser seems to fail as soon as there is one empty line.

Steps to reproduce

  • Add a .env.dist in the project with an empty line
VAR1=toto

VAR2=tata
  • Add this .gitlab-ci.yml
image:
  name: docker:19.03.13

stages:
  - first

first:
  stage: first
  script:
    - echo 'First !'
  artifacts:
    reports:
      dotenv: .env.dist

Example Project

https://gitlab.com/Glideh/dotenv-failer

What is the current bug behavior?

Job stage log:

$ echo 'First !'
First !
Uploading artifacts for successful job
Uploading artifacts...
.env.dist: found 1 matching files and directories  
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/2238340898/artifacts?artifact_format=gzip&artifact_type=dotenv: 400 Bad Request (Invalid Format)  id=2238340898 responseStatus=400 Bad Request status=400 token=bt2szSaB
WARNING: Retrying...                                context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/2238340898/artifacts?artifact_format=gzip&artifact_type=dotenv: 400 Bad Request (Invalid Format)  id=2238340898 responseStatus=400 Bad Request status=400 token=bt2szSaB
WARNING: Retrying...                                context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "dotenv" to coordinator... POST https://gitlab.com/api/v4/jobs/2238340898/artifacts?artifact_format=gzip&artifact_type=dotenv: 400 Bad Request (Invalid Format)  id=2238340898 responseStatus=400 Bad Request status=400 token=bt2szSaB
FATAL: invalid argument                            
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1

What is the expected correct behavior?

Job stage log:

$ echo 'First !'
First !
Uploading artifacts for successful job
Uploading artifacts...
.env.dist: found 1 matching files and directories  
Uploading artifacts as "dotenv" to coordinator... 201 Created  id=2238336129 responseStatus=201 Created token=mN9QdWhK
Cleaning up project directory and file based variables
Job succeeded

Environments

I discovered that on my personnal 14.0.0 full docker gitlab installation.
Then I've also been able to reproduce on gitlab.com (linked example project).

Edited by 🤖 GitLab Bot 🤖