fix(variable): use StringArrayVar to preserve special characters in --key values#221
Conversation
…key flag
StringToStringVar uses an internal CSV parser that cannot handle values
containing ${}, commas, or other special characters. This causes values
like ${POSTGRESQL.POSTGRES_CONNECTION_STRING} to be truncated or emptied.
Switch to StringArrayVar and manually split each entry on the first "="
only, preserving arbitrary characters in values.
Fixes zeabur#201
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Caution Review failedPull request was closed or merged during review WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing as duplicate of #206 which addresses the same issue. Sorry for the overlap! |
Summary
variable createandvariable update--keyflag silently truncating or emptying values that contain${}, commas, or other special charactersStringToStringVarP(which uses an internal CSV parser) toStringArrayVarPwith manualSplitNon the first=DATABASE_URL=${POSTGRESQL.POSTGRES_CONNECTION_STRING}now work correctlyRoot Cause
StringToStringVarPinternally uses Go'sencoding/csvreader to parseKEY=VALUEpairs. This parser treats${}, commas, and quotes as special characters, causing values to be silently truncated or emptied.Changes
internal/cmd/variable/create/create.goStringToStringVarPwithStringArrayVarP+parseRawKeys()internal/cmd/variable/update/update.goUsage (unchanged)
Test plan
variable create -k 'KEY=${REF}'preserves${REF}in the valuevariable create -k 'KEY=val,with,commas'preserves commasvariable update -k 'KEY=new_value'works correctly-kflags work:-k 'A=1' -k 'B=2'Fixes #201
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
--key/-kflag in variable create and update commands to accept repeatableKEY=VALUEformat.=) within variable values.Bug Fixes