Open alexkwolfe opened 6 years ago
The lead handler has code like this:
# Parse the value, if necessary
parsed =
if _.isArray(value)
value
else
types.parse(typeName, value, req)
We could move the _.isArray()
test into the parse
function exported by this module. Then we could remove it from the handler. This would make the behavior consistent on the inbound and outbound side.
My concern, though, is that if an integration declares the type as phone
it may be hardcoded to expect a phone object. So solving it this way will just push the error into the integration.
Maybe a better solution would be to only parse the first value and discard the second. What do you think @cgrayson?
I think I like the idea of parsing only the first value and discarding others best. It's simple, consistent, and non-breaking. From a user standpoint, it seems totally sensible that if I send an array of values into a field that accepts one, that something has to be lost. If I were the user, I'd consider myself lucky to have it keep the first intact instead of blowing up or doing something else weird. :-)
There was a batch of leads submitted where an array of phone numbers was provided in the
phone_1
field. On the inbound side, the array was not parsed by the phone type, and no error occurred.But on the outbound side, an integration declared a request variable as a
phone
type. This caused an unhandled error and therefore the handler to crash.