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 -f for 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"].

Resolves #8216 Resolves #7467

How has this been tested?

  • go test ./internal/commands/api/... -race passes
  • make lint passes
  • New test cases in api_test.go for magicFieldValue: JSON array, JSON object, nested JSON, invalid JSON with [ prefix, invalid JSON with { prefix
  • Updated http_test.go for httpRequest: pre-parsed JSON array field, JSON object field, plain string unchanged
  • New groupGraphQLVariables tests: JSON array variable, JSON object variable

Merge request reports

Loading