# ES password containing comma can't be passed as environment variable

**URL:** <https://discuss.elastic.co/t/es-password-containing-comma-cant-be-passed-as-environment-variable/294450>\
**Category:** Beats\
**Tags:** heartbeat\
**Created:** [January 14, 2022, 8:52pm UTC](https://discuss.elastic.co/t/es-password-containing-comma-cant-be-passed-as-environment-variable/294450 "2022-01-14T20:52:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BitPatty](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bitpatty/32/100347_2.png) [@BitPatty](https://discuss.elastic.co/u/BitPatty)\
**Post date:** [January 14, 2022, 8:52pm UTC](https://discuss.elastic.co/t/es-password-containing-comma-cant-be-passed-as-environment-variable/294450/1 "2022-01-14T20:52:25Z")

</div>

I'm passing the password as environment variable to `heartbeat.yml` on ES 7.16.1 as follows:

heartbeat.yml:

```auto
output:
  elasticsearch:
    password: '${ELASTICSEARCH_PASSWORD}'

```

When using `ELASTICSEARCH_PASSWORD="foo,bar"` the value is parsed as an object instead of a string (I assume due to the comma being treated as separator?) and throws an error `Exiting: error initializing publisher: can not convert 'object' into 'string' accessing 'output.elasticsearch.password' (source:'/app/heartbeat.yml')`. However, the same configuration works fine when no comma is used.

Interestingly enough, when I use the following configuration with a hardcoded password containing a comma it works just fine:

```auto
output:
  elasticsearch:
    password: 'foo,bar'

```

How can I tell the config to treat the comma as a literal comma?

---

<div class="post-metadata">

**Author:** ![abdulz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdulz/32/97601_2.png) [@abdulz](https://discuss.elastic.co/u/abdulz)\
**Post date:** [January 17, 2022, 4:36pm UTC](https://discuss.elastic.co/t/es-password-containing-comma-cant-be-passed-as-environment-variable/294450/2 "2022-01-17T16:36:25Z")

</div>

Hi @BitPatty,

Thank you for your first post and welcome to the community!

An environment variable containing a `,` makes the value as list (a complex value). Please [see](https://www.elastic.co/guide/en/beats/libbeat/current/config-file-format-env-vars.html#_specify_complex_objects_in_environment_variables).

You can go around this by wrapping your env var's value in escaped double quotes so that the parser treats it as a string e.g.

```auto
ELASTICSEARCH_PASSWORD='"foo,bar"'

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 14, 2022, 6:37pm UTC](https://discuss.elastic.co/t/es-password-containing-comma-cant-be-passed-as-environment-variable/294450/3 "2022-02-14T18:37:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
