feat(api): replace string array regex with json.Unmarshal for -F flag
Description
Replace stringArrayRegexPattern with json.Unmarshal in magicFieldValue
for -F flag values starting with [ or {.
The regex only matched [[:lower:]_], so values with hyphens, uppercase, or
digits silently degraded to strings. Broadening the regex maintains a
non-standard syntax with no stable stopping point. This also affects LLM tool
use, where -F is the documented path for typed values.
With this change:
- Valid JSON arrays and objects are parsed directly
(e.g.
-F 'topics=["my-topic","GitLab"]') - Invalid JSON returns an actionable error guiding users to correct syntax
or
-ffor literal strings - All existing type inference (integers, booleans, null,
@file, placeholders) is unchanged
Breaking change: The unquoted shorthand [api,read_api] previously
accepted by the regex now returns an error. Use proper JSON syntax:
["api","read_api"].
Related Issues
How has this been tested?
-
go test ./internal/commands/api/... -racepasses -
make lintpasses - New test cases in
api_test.goformagicFieldValue: JSON array, JSON object, nested JSON, invalid JSON with[prefix, invalid JSON with{prefix - Updated
http_test.goforhttpRequest: pre-parsed JSON array field, JSON object field, plain string unchanged - New
groupGraphQLVariablestests: JSON array variable, JSON object variable