Throw error when requiredEnvVars are missing
See original GitHub issue👋 @JasonEtco thanks for providing this utility, it’s super helpful!
What are your thoughts on throwing an error (saying, e.g. GitHub Actions environment unavailable
) when the required environment variables are missing? My thoughts are this would make it a little more explicit when the Actions environment isn’t set, and would allow me to decide how to proceed (should I abort, or try and do something useful).
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
In Javascript, how can I throw an error if an environmental ...
Helper function that throws if the environment variable doesn't exist: ... null)) { throw ("missing env var for " + name); } return...
Read more >when variable is defined as system variable but not .env file ...
The 'Missing environment variable' error is thrown if any value from the ... config (to verify you populate all required env vars).
Read more >envalid - npm
There are two functions that handle errors: env.onError (used when there are any missing required env vars or validation errors) and env.
Read more >Force Ansible to throw out error when vars is missing in yml?
Is it possible to force Ansible when replacing the var in yml files, which is undefined, throw out an error instead silently replaced...
Read more >Problems with Environment Variables
Error message = "Environment variable set to non-existent directory" ... If the name is missing from the list, the ONLY possibilities are :....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh by the by @swinton - this may or may not work for your use-case, but you can define what events your Action is designed to be triggered by, which would help prevent
undefined
events!@swinton 👋 I’m here to report that I reverted #41 in #70 😅 I discovered that some environment variables are not present in every event, so to depend on the existence of some but not all is as unreliable as none (that’s confusing but I think it’s correct). I also encountered some friction while using this in
v2.0.0-beta.1
- this was expected, but still not a great experience.I’m going to close this issue because after investigating it and trying it out, I don’t believe that the predictability is worth the friction, especially because
actions-toolkit
is a good way to start writing Actions, where newcomers to the platform aren’t familiar with the nuances of where theevent.json
lives, what env vars do what, etc.