Skill
wizard
Harness and version
Not harness-specific: the bug is in plain bash in skills/engineering/wizard/template.sh. Reproduced at f3fc563 with GNU bash 5.3.20 and 3.2.57 (macOS /bin/bash).
Model and effort
N/A. Found by testing the template's _existing and write_env functions directly. No model behaviour is involved.
What happened
This follows up #770. That fix made write_env write single-quoted values. _existing undoes that single-quote form, but it returns any other existing form verbatim. A .env that already holds a common double-quoted dotenv line gives the quotes back as part of the value. If the user presses Enter to keep the current value, write_env stores the quotes as literal characters, and set_secret sends them to CI.
Repro with dummy values (_existing and write_env loaded from template.sh):
ENV_FILE=$(mktemp)
printf 'API_KEY="dummy-value"\n' > "$ENV_FILE"
write_env API_KEY "$(_existing API_KEY)" # what "Enter keeps current" does
cat "$ENV_FILE"
# API_KEY='"dummy-value"' <- the credential now contains the quotes
What you expected
The comment above _existing says "with write_env's quoting undone", and ask/ask_secret say "Enter keeps current". Keeping the current value should leave the credential unchanged: API_KEY="dummy-value" should be offered as dummy-value.
Paired regression case: a fix must not break the opposite case. A value that really contains quotes, which write_env stores as API_KEY='"dummy-value"', must read back as "dummy-value". A naive "strip double quotes as well" decodes both layers and changes that credential.
Suggested fix: choose the decoder from how the value is stored, and make the branches exclusive:
if [[ "$value" == \'*\' ]]; then value="${value:1:${#value}-2}"; value="${value//"$sq"/\'}"
elif [[ ${#value} -ge 2 && "$value" == \"*\" ]]; then
value="${value:1:${#value}-2}"
[[ "$value" == *[\\\$\"]* ]] && return 1 # escapes or $: can't decode safely; ask again
fi
Tested against both cases above, plus write → read → write round trips of values that contain ", ', $, \ and spaces.
Skill
wizardHarness and version
Not harness-specific: the bug is in plain bash in
skills/engineering/wizard/template.sh. Reproduced at f3fc563 with GNU bash 5.3.20 and 3.2.57 (macOS/bin/bash).Model and effort
N/A. Found by testing the template's
_existingandwrite_envfunctions directly. No model behaviour is involved.What happened
This follows up #770. That fix made
write_envwrite single-quoted values._existingundoes that single-quote form, but it returns any other existing form verbatim. A.envthat already holds a common double-quoted dotenv line gives the quotes back as part of the value. If the user presses Enter to keep the current value,write_envstores the quotes as literal characters, andset_secretsends them to CI.Repro with dummy values (
_existingandwrite_envloaded fromtemplate.sh):What you expected
The comment above
_existingsays "with write_env's quoting undone", andask/ask_secretsay "Enter keeps current". Keeping the current value should leave the credential unchanged:API_KEY="dummy-value"should be offered asdummy-value.Paired regression case: a fix must not break the opposite case. A value that really contains quotes, which
write_envstores asAPI_KEY='"dummy-value"', must read back as"dummy-value". A naive "strip double quotes as well" decodes both layers and changes that credential.Suggested fix: choose the decoder from how the value is stored, and make the branches exclusive:
Tested against both cases above, plus write → read → write round trips of values that contain
",',$,\and spaces.