When setting the environment=
parameter in a configuration file, the %
sign returns a Error: Format string 'KEY="%"' for 'environment' is badly formatted
error.
e.g.
Okay: environment=SECRET_KEY="*wi4h$kqxp84f3w6uh8w@l$0(+@x$3cr&)z^lmg+pqw^6wkyi"
Broken: environment=SECRET_KEY="*wi4h$kqxp84f3w6uh8w@l$0(+@x$3cr&)z^lmg+pqw^6wky%i"
Broken:environment=FOO="%"
Broken: environment=FOO="\%"
Broken:
environment=SECRET_KEY="*wi4h$kqxp84f3w6uh8w@l$0(+@x$3cr&)z^lmg+pqw^6wky%i"
You should be able to include a %
by using %%
.
Supervisor uses Python string interpolation when parsing the config file, so you can test it like this:
$ python
>>> "*wi4h$kqxp84f3w6uh8w@l$0(+@x$3cr&)z^lmg+pqw^6wky%i" % {}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: %d format: a number is required, not dict
With %%
:
>>> "*wi4h$kqxp84f3w6uh8w@l$0(+@x$3cr&)z^lmg+pqw^6wky%%i" % {}
'*wi4h$kqxp84f3w6uh8w@l$0(+@x$3cr&)z^lmg+pqw^6wky%i'
Hi,
I faced a similar issue with config in environment=
parameter inside [supervisord]
block.
I have a parameter with %
sign. I tried the suggested solution (using 2 %
signs), but I haven't been able to resolve the issue.
The sample string to try with: x1it3km%2BTVmkRsQ
Getting following error for this string
Error: Format string 'SECRET="x1it3km%2BTVmkRsQ"' for 'supervisord.environment' is badly formatted: unsupported format character 'B'
I think this has something to do with a number following the %
sign, but I'm not sure.
Any ideas?
@chinmaybhoir it is the case... it consider %2 like a special caracter or something like that.... In my cas i was on Django so i just remove every % in the key and it worked fine
It would be amazing if supervisor could automatically escape %
s in strings (e.g., %(ENV_SECRET_KEY)
currently expands to x1it3km%2BTVmkRsQ
, which is invalid, but I'd like for it to expand to x1it3km%%2BTVmkRsQ
. This way, I wouldn't have to change my Django secret key in order to make supervisor happy.
Most helpful comment
You should be able to include a
%
by using%%
.Supervisor uses Python string interpolation when parsing the config file, so you can test it like this:
With
%%
: