dstack icon indicating copy to clipboard operation
dstack copied to clipboard

[Bug]: `env` validation inconsistency in task/service/dev-environment configurations

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

Steps to reproduce

  1. Create a task configuration with env setting as a list of strings:
env:
  - VAR-1=value
  - VAR:2=value
  1. Apply the configuration: dstack apply -f test-task.dstack.yml → validation errors:
3 validation errors for ApplyConfigurationRequest
__root__ -> TaskConfigurationRequest -> env -> 0
  string does not match regex "^[a-zA-Z_][a-zA-Z0-9_]*(=.*$|$)" (type=value_error.str.regex; pattern=^[a-zA-Z_][a-zA-Z0-9_]*(=.*$|$))
__root__ -> TaskConfigurationRequest -> env -> 1
  string does not match regex "^[a-zA-Z_][a-zA-Z0-9_]*(=.*$|$)" (type=value_error.str.regex; pattern=^[a-zA-Z_][a-zA-Z0-9_]*(=.*$|$))
__root__ -> TaskConfigurationRequest -> env
  value is not a valid dict (type=type_error.dict)
  1. Update the configuration, replace the env list with a mapping:
env:
  VAR-1: value
  VAR:2: value
  1. Apply the configuration again: dstack apply -f test-task.dstack.yml → OK, no validation errors

Actual behaviour

Variable name validation rules depend on the env format.

Expected behaviour

Variable names are validated uniformly, that is, hyphens, colons, etc. are either valid or invalid in both env formats.

dstack version

0.18.8

Server logs

No response

Additional information

No response

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