Fix string regression in attribute parsing (#2759)

In #2721, the ability for key-only values was added via using a
wrapperspb.StringValue that could be null. This introduced a bug because
originally the default case for `-attr` was to get the string value but
instead it used the incoming value as-is to allow for nulls; the null
check was moved up later but the original behavior was not restored. As
a result, non-explicitly-quoted strings carried through the
wrapperspb.StringValue, resulting in a map for the value in JSON instead
of a string.

This also fixes the ability to set explicitly quoted strings.
This commit is contained in:
Jeff Mitchell authored and GitHub committed 2023-01-05 13:25:59 -05:00
1 parent 9135cc7668
commit b286060ea8
3 files changed
+48 -18

No files matched your search

+2 -3
View File
@@ -1020,9 +1020,8 @@ func (c *combinedSliceValue) Set(val string) error {
if err != nil && !errors.Is(err, parseutil.ErrNotAUrl) {
return fmt.Errorf("error checking if value is a path: %w", err)
}
if pathParsedValue != "" {
ret.Value = wrapperspb.String(pathParsedValue)
}
// This will either be the round-tripped value or the substituted value
ret.Value = wrapperspb.String(pathParsedValue)
}
*c.target = append(*c.target, ret)