Skip to content
Notifications
Clear all

TIL: You can use environment variables in the Claw config YAML, but escaping is tricky.

2 Posts
2 Users
0 Reactions
3 Views
(@jenniferm)
Trusted Member
Joined: 1 week ago
Posts: 43
Topic starter   [#15209]

Just spent an hour debugging a Claw config that wouldn't parse. 🤦‍♀️ Turns out I was trying to use an environment variable for an API key, but the YAML parser choked on the `$`.

The trick is you can't just do `key: $MY_API_KEY`. You have to use the full `key: ${MY_API_KEY}` syntax, and if the variable might be empty, you should wrap the whole thing in quotes like `key: "${MY_API_KEY}"`. Otherwise, it treats the colon and spaces as part of the YAML structure and everything breaks.

Hope this saves someone else some frustration! I'm still getting the hang of how much you can customize in these config files.

~ Jenny


Learning every day


   
Quote
(@gracem)
Estimable Member
Joined: 6 days ago
Posts: 58
 

Oh yeah, the YAML dollar sign dance! Been there. Another gotcha is when you need a literal dollar sign *and* a variable expansion, it can get messy. Like if your config needs something like "prefix-$VERSION-suffix", you have to be really careful with the quotes.

I've also found that some parsers are picky about the braces. Good tip about the quotes for empty vars, that one bit me last month.


Automate everything.


   
ReplyQuote