Date
1 - 6 of 6
Environment variables with special characters not handled correctly?
Jonas Rosland
Hi all,
I am having an issue with an environment variable containing special characters that doesn't seem to picked up correctly by CF. I run `cf set-env appname WORDPRESS_BEARER 1NNKhb5&Nfw$F(wqbqW&9nSeoonwAYz7#j2M1KKY!QU(Wbs(a)8xwjr6Q$hg(IPqcd` (obviously not my currently correct key) and then use it in this Ruby app: https://gist.github.com/jonasrosland/08b5758eaa9098a81cf8 When I check the output the app complains about the API key being incorrect, when it is, in fact, correct. If I set it manually in the application it works, but that is of course not a good practice. I've also verified that the environment variable does get picked up by the application by adding some logging output to show the API key, but it still won't work. I'm wondering if this is because of the special characters in the environment variable? Thanks in advance, Jonas Rosland |
|
Daniel Mikusa
It's possible that your shell is escaping the characters, like the '$'.
Try `cf set-env appname WORDPRESS_BEARER '1NNKhb5&Nfw$F(wqbqW&9nSeoonwAYz7#j2M1KKY!QU(Wbs(a)8xwjr6Q$hg(IPqcd'`. Note the single quotes around the value of the environment variable. Or set the environment variable in a manifest.yml file. Also, run `cf env <app-name>` to confirm the value is being set correctly. Thanks, Dan On Thu, Sep 24, 2015 at 1:57 PM, Jonas Rosland <jonas.rosland(a)emc.com> wrote: Hi all, |
|
Dieu Cao <dcao@...>
Hi Jonas,
toggle quoted message
Show quoted text
You'll need to escape the special characters like $. See this tracker story for some background: https://www.pivotaltracker.com/story/show/76655240 -Dieu On Thu, Sep 24, 2015 at 11:14 AM, Daniel Mikusa <dmikusa(a)pivotal.io> wrote:
It's possible that your shell is escaping the characters, like the '$'. |
|
Jonas Rosland
Hi Dieu and Daniel,
I did set the environment variable like you suggest Daniel, I should've showed that in my example. I see now that the app wrongly removes the $ characters and the character after it, I didn't notice that before. `cf env appname` shows the correct environment variable, so I guess I will have to do some escaping of characters in my app? Best regards, Jonas Rosland |
|
Daniel Mikusa
Sorry, sounds like escaping is the only option here for an environment
variable. If you don't want to escape, I think you could create a user provided service, provide the value through there and bind that to your app. That'll come into VCAP_SERVICES which, if I read the PT story right, shouldn't need any extra escaping. Dan On Thu, Sep 24, 2015 at 3:10 PM, Jonas Rosland <jonas.rosland(a)emc.com> wrote: Hi Dieu and Daniel, |
|
Jonas Rosland
Hi Daniel and Dieu,
Finally after much trial and error I finally got it working. I created a user-provided service and then called on it from my application. I've documented the steps for anyone else wanting to know how to work with these variables (clearer documentation with examples maybe?). Here's the documentation and example application: https://gist.github.com/jonasrosland/08b5758eaa9098a81cf8 Thanks for all your help! Best regards, Jonas Rosland |
|