dstack icon indicating copy to clipboard operation
dstack copied to clipboard

[Feature]: Allow to specify required env variables in task/service/dev-environment configuration when a mapping is used

Open un-def opened this issue 1 year ago • 1 comments

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

un-def avatar Aug 06 '24 07:08 un-def

I'd drop mapping support instead

peterschmidt85 avatar Aug 29 '24 07:08 peterschmidt85

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Feb 11 '25 01:02 github-actions[bot]

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.

github-actions[bot] avatar Apr 21 '25 02:04 github-actions[bot]