Environment keys containing dash - resolve their value to NaN.
Base environment
{
"mykey": "myvalue",
"my-key": "my-value"
}
URL
http://{{ mykey }}/{{ my-key }}
URL PREVIEW
http://myvalue/NaN
Hmm, I swear there was an issue on this before but I can't find it.
There is currently a warning that shows up after editing an environment if one of your variables contains dashes. This is because nunjucks (the rendering engine Insomnia uses) interprets this as subtraction (ie. {{ my - key }}). Maybe a more prominent message is needed?

After updating I have this visual message al well.
Good enough.
@gschier Maybe not let it set the value? have an alert?
I ran into this today testing insomnia as a potential replacement for postman for my small team. I feel like somewhat of a goon having now actually read the error message, but I did just spend 10 minutes trying to figure out what was going on and only found the solution when going to file a bug and finding this first.
Perhaps it's because I saw it as a warning message rather than an error? I expect errors to be red, not orange, and it seems a little weird that it'd even let me save a config it knows it's broken. Wouldn't it be better to disable the "Done" button while it's invalid?
@seangarner it's a warning because technically there _are_ use cases where a dash is acceptable.
One way to make this better might be to treat the scenario as an error but provide an "I know what I'm doing" button to dismiss the error in the future. Thoughts?
Yes that'd work well @gschier.
I'm very curious what the use case for doing maths in a property name is. :thought_balloon:
Well, it's only math if you use it as a variable like {{ foo-bar }}. You may want dashes in a key name for other reasons, like if you wanted to store free-form JSON in your environment that happens to use dashes. Plugins can also reference the environment, which may or may not use dashed key names for the use case.
There definitely aren't very many use cases, but even if there's only a small chance that it might be useful, I don't want to fully prevent it from happening.
had the same issue using "api-token" my post was then sending NaN. At least now I know a work around which is to use apiToken. Would be good if this were in the docs maybe something along the lines of characters not to use.
@gschier , this one is actual in 6.5.4 and there is no such warning shown

@gschier I just ran into this problem. No error or warning message is shown.
Same here on latest version. There are no errors when setting up environment, but the resolution is "NaN".
Can confirm, too
Is there any workaround to this? A way to escape the dash?
Even if a user renames all their env vars to avoid a hyphen, this will be a persistent problem on imports from postman, which doesn't seem to have this issue.
I ran into this today and was extremely confused by it, only this post lead me to understanding what I was doing wrong.
This problem still persists in version 7.0.1.
Hi guys! Is there something to expect for fixing the issue with keys, written with dash? In 7.0.3 if I write key with dashes it will be replaced with NaN. Should I rewrite all params in camelCase or without dashes?


I am still getting variables resolving to NaN, when the environment variables have hyphens in them in v7.0.3.
Same problem in v7.0.5
Due to using Nunjucks as the underlying template engine, there is no way to support names with dashes.
The UI should be updated to ensure the user cannot make this mistake by accident.
Ditto @gschier 's post. The ui should block this. Wasted an hour fiddling with this (insomnia newbie)...
@gschier maybe also a warning when importing data that contains names with dashes too. That's where I was stuck for half a day, since I didn't get the warning you mentioned in a previous comment having imported data rather than created the variables myself.
Not sure how difficult that would be to implement, mind you.
Guys, comment under #1666 because it's still open. Cheers!
This is a ridiculous limitation
Re-opening this as a potential fix is in the works (#2601), and there was a lot of activity on this (and duplicate) issues. 馃槃
Most helpful comment
Same here on latest version. There are no errors when setting up environment, but the resolution is "NaN".