Make `convertObjectProps` correctly handle string arrays
What does this MR do?
Fixes a bug in the convertObjectProps
utility function (used by ever-popular convertObjectPropsToCamelCase
and convertObjectPropsToSnakeCase
) so that it correctly handles string arrays.
Previously, something like this would throw an error:
convertObjectPropsToSnakeCase({ milestones: ['1.2', '1.3']})
This is because convertObjectProps
would attempt to convert the "property names" of the array, which in this case are "0"
and "1"
. The convertToSnakeCase
utility doesn't handle property names with numbers (see the regex it uses here), so it throws an error when trying to convert these properties. (This issue should also be addressed, probably in a separate MR. Update: Opened an MR for this here: !33528 (merged).)
The fix is to avoid running the conversion function on the property names if the object being converted is an array.
I'm a little bit surprised we haven't run into this before
Context
I ran into this issue when trying to use convertObjectPropsToSnakeCase
with a Release API payload, which includes a property that looks like this:
{
milestones: ["12.1", "12.2"]
}
Here's the MR: !33434 (merged)