Skip to content

Instantly share code, notes, and snippets.

@liuxd
Last active June 12, 2024 11:29
Show Gist options
  • Save liuxd/a1cf21fcc352ddd1dee06e8ca9e64985 to your computer and use it in GitHub Desktop.
Save liuxd/a1cf21fcc352ddd1dee06e8ca9e64985 to your computer and use it in GitHub Desktop.
[Crash Gitlab Pipeline by Deleting an Empty Line.] #Bug
tags
bug
fun

Crash Gitlab Pipeline by Deleting an Empty Line.

In the CI process, there are some lines about setting configuration files like this:

- docker exec webcontainer bash -c "cat .env.gitlab-ci >> .env"

The .env.gitlab-ci is like this:

DATABASE_URL=mysql://xxx:yyy@dbcontainer:3306/dbname?serverVersion=5.7

The .env is like this:

# some useful stuff bablala

LOCK_DSN=semaphore  
###< symfony/lock ###

What I did is removing the empty line in end of .env, then it became:

# some useful stuff bablala

LOCK_DSN=semaphore  
###< symfony/lock ###

Then the pipeline failed and gave an error:

An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused

WHY?

Because the deleted empty line matters. With it, the .env would be like:

# some useful stuff bablala

LOCK_DSN=semaphore  
###< symfony/lock ###
DATABASE_URL=mysql://xxx:yyy@dbcontainer:3306/dbname?serverVersion=5.7

Without it, .env would be like:

# some useful stuff bablala

LOCK_DSN=semaphore  
###< symfony/lock ###DATABASE_URL=mysql://xxx:yyy@dbcontainer:3306/dbname?serverVersion=5.7

Bingo! The db connection gets crashed!!!

So, don't messy up empty lines. They matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment