Environment Variables in Snippets
Options
![Georges Duverger](https://us.v-cdn.net/6037124/user_avatars/1709796.jpg)
Georges Duverger
Trusted Xano Expert ✭
I created a snippet for one of my endpoints. In it, I use an environment variable. That variable got added to the new workspace that installed the snippet — that's good. What I didn't expect to happen is that the *value* of that environment variable got copied as well. Is that the expected behavior or a bug?
Comments
-
Hi, Georges. The values contained inside an endpoint will be transferred with the snippet. This is expected behavior.
-
I don't see where this behavior is documented - how could Georges expect it? User-generated environment variables are almost always secrets, so this could have some side-effects. Perhaps if this is to be the way the system works it'd be worth adding a note/warning on this to the docs?
-
at the time of Snippet creation you should be able to delete the values contained in any included environment variables. If you do not, then the values will be included in the Snippet
-
I hear your point, however, Environment Variables are not exclusively used (although often times are) for keys/secrets so that needs to be considered
-
I saw the option to remove records from a table but not the option to delete the values of environment variables. Could you point out to me how I would do that?
-
That's fair. It's definitely a product decision. Just for the record, we were pretty surprised to observe that behavior but it might be just us. 🤷♂️
-
Thanks for your responses. I'd agree with Ray's suggestion to add a warning in the doc. We came pretty close to sharing private API keys with one of our users. 😬
-
- here's an example:[CleanShot 2022-06-10 at 14.36.54.gif]
-
- We have warnings in a couple different places but maybe they should be more in your face like a pop out and confirmation
[CleanShot 2022-06-10 at 14.37.40.png][CleanShot 2022-06-10 at 14.37.23.png] -
There is definitely a warning in red, but maybe we should turn that into a checkbox confirmation since it is easy to skim over things.
-
Good call. Added a note about this in the docs!
-
Thanks a lot for your responses. I might be doing something wrong but I'm not seeing the Environment Variables section in the Snippet creation drawer (see attached screenshot). 🤔[Screen Shot 2022-06-13 at 4.31.12 PM.png]
-
they would only show up if they are used in an API endpoint included in the snippet. Does the one endpoint in that screenshot use an environment variable?
-
Yes, it does. Though, not in a very realistic way. I just returned it in the Response for testing purposes (see attached screenshot).[Screen Shot 2022-06-13 at 4.40.35 PM.png]
-
- got it, maybe not the most realistic but we could add something there. I also noticed in exploring this, if there is no value for your environment variable (and it's used in the function stack 😉) there will be no warning. Currently, it's only when it is holding a value (and in the function stack) that the warning message will show.
-
Ah! I see it now when I use it in the Function stack. My bad. Thank you very much for the clarification. 💪
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback