[Feature]: Allow to specify required env variables in task/service/dev-environment configuration when a mapping is used
Problem
env setting in task/service/dev-environment configurations has two formats, it's either a list of strings or a mapping. When the list format is used, it's possible to specify a variable without value, in this case the value must be provided via a CLI argument or an enviroment variable:
env:
- REQUIRED_VAR
- VAR_WITH_EMPTY_VALUE=
$ dstack apply
Environment variable REQUIRED_VAR is not set
$ dstack apply -e REQUIRED_VAR=value
...
Submit a new run? [y/n]
$ export REQUIRED_VAR=value
$ dstack apply
...
Submit a new run? [y/n]
This is not possible with the mapping format:
env:
REQUIRED_VAR:
VAR_WITH_EMPTY_VALUE: ''
$ dstack apply
2 validation errors for ApplyConfigurationRequest
__root__ -> TaskConfigurationRequest -> env
value is not a valid list (type=type_error.list)
__root__ -> TaskConfigurationRequest -> env -> REQUIRED_VAR
none is not an allowed value (type=type_error.none.not_allowed)
Solution
Treat null (an implicit value in YAML mapping if no value provided) as a marker of a required variable.
Workaround
No response
Would you like to help us implement this feature by sending a PR?
No
I'd drop mapping support instead
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale. Please reopen the issue if it is still relevant.