Bug Description
When using variable create --key to set environment variables containing Zeabur variable references like ${POSTGRESQL.POSTGRES_CONNECTION_STRING}, the value gets truncated or emptied.
Steps to Reproduce
npx zeabur@latest variable create \
--id <service-id> \
--key 'DATABASE_URL=${POSTGRESQL.POSTGRES_CONNECTION_STRING}' \
-i=false --json
Expected: DATABASE_URL set to ${POSTGRESQL.POSTGRES_CONNECTION_STRING}
Actual: DATABASE_URL set to empty string ""
Even with single quotes, the value is lost. The same issue affects variable update.
Root Cause
The --key flag uses Cobra's StringToStringVarP which parses KEY=VALUE pairs using an internal CSV parser. This parser cannot handle values containing ${}, commas, or other special characters.
Source: /internal/cmd/variable/create/create.go
cmd.Flags().StringToStringVarP(&opts.keys, "key", "k", nil, "Key value pair of the variable")
Suggested Fix
Switch from StringToStringVarP to StringArrayVarP, then manually split each entry on the first = only (similar to how Helm handles --set flags). This preserves arbitrary characters in values.
// Before
cmd.Flags().StringToStringVarP(&opts.keys, "key", "k", nil, "...")
// After
var rawKeys []string
cmd.Flags().StringArrayVarP(&rawKeys, "key", "k", nil, "...")
// Then in Run: split each on first "="
for _, kv := range rawKeys {
parts := strings.SplitN(kv, "=", 2)
key, value := parts[0], parts[1]
}
Alternatively, support --env-file for loading variables from a file.
Workaround
Use GraphQL API updateEnvironmentVariable(serviceID, environmentID, data: Map!) mutation directly, passing the value via JSON (no shell escaping issues).
Environment
- CLI version: 0.14.0
- OS: macOS (Apple Silicon)
- Shell: zsh
Bug Description
When using
variable create --keyto set environment variables containing Zeabur variable references like${POSTGRESQL.POSTGRES_CONNECTION_STRING}, the value gets truncated or emptied.Steps to Reproduce
Expected:
DATABASE_URLset to${POSTGRESQL.POSTGRES_CONNECTION_STRING}Actual:
DATABASE_URLset to empty string""Even with single quotes, the value is lost. The same issue affects
variable update.Root Cause
The
--keyflag uses Cobra'sStringToStringVarPwhich parsesKEY=VALUEpairs using an internal CSV parser. This parser cannot handle values containing${}, commas, or other special characters.Source:
/internal/cmd/variable/create/create.goSuggested Fix
Switch from
StringToStringVarPtoStringArrayVarP, then manually split each entry on the first=only (similar to how Helm handles--setflags). This preserves arbitrary characters in values.Alternatively, support
--env-filefor loading variables from a file.Workaround
Use GraphQL API
updateEnvironmentVariable(serviceID, environmentID, data: Map!)mutation directly, passing the value via JSON (no shell escaping issues).Environment