python-dotenv: Multiline value not working as expected, better doc example needed

I have this .env file

CLOUDKARAFKA_CA="-----BEGIN CERTIFICATE-----
MIIDAzCCAeugAwIBAgIJAL7UBqvWBRglMA0GCSqGSIb3DQEBCwUAMBgxFjAUBgNV
someMoreLines
+HPBLZVg3o4jtzOJJNnaGCAcAHsm6PkqBhTUhM113r8MWlsR6eAIhIVtdRAxmjaw
6f7ARs8C8A==
-----END CERTIFICATE-----
"
CLOUDKARAFKA_CERT="-----BEGIN CERTIFICATE-----
MIICpzCCAY8CCQCA4JIEmpl1oTANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDDA12
someMoreLines
SSgZPE8qiN/jucTdLSLRQ0igohq4EnAg8QHXReX2oIlSZb7i8wxCqK/T+9WU0+vB
ToJ+bM0OCJ4d22I=
-----END CERTIFICATE-----
"
CLOUDKARAFKA_TOPIC_PREFIX="aj9g740d-"
CLOUDKARAFKA_BROKERS="velomobile-02.srvs.cloudkafka.com:9094,velomobile-01.srvs.cloudkafka.com:9094,velomobile-03.srvs.cloudkafka.com:9094"

When I use this .env file, the CLOUDKARAFKA_CA and CLOUDKARAFKA_CERT key are both “-----BEGIN CERTIFICATE-----”

image

Notice the extra ", Am I doing something wrong, please help

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I’m closing this issue, a multi-line value should use the \n newline delimiter and python-dotenv will correctly put that in the system environment variable.

@itaditya the way you have set the value won’t be supported. Please use the \n to indicate newlines.

I have opened #142 to fix this issue. The changes I’m proposing don’t break any existing tests and address @itaditya’s use case.

I know this issue has been closed, but I think it’s important to support implicit (as opposed to manually adding \n chars) newlines in .env files so that it more closely matches the behavior of other languages, not to mention a simple source .env

Cool then, I’ll make one today

Why do you think I’m defending my PR when I’m even suggesting the other PR should be merged, which in turn would replace the changes my PR made.

Great that you realized that this repo lacks documentation about the feature. Why not make your contribution worth more by sending a PR for the improvement to README.md?