Open AlexJoom opened 7 months ago
The difference here is in the arity of the relationship. Location and telephone (and e-mail) are 0..n
relationships, which means they expected lists. To indicate a contact has none, it expects an empty list ([]
) instead of null
. When the field is omitted, the default is []
and not null
. By contrast, the Person is a 0..1
relationship, which means that it expects an integer or null
(the fact that it allows null is derived from the fact that the property is not required). This explains the behavior you are seeing.
We should definitely provide better error messages here (#85), but I do not think we should allow null
as valid input.
For example, here it should read something along the lines of:
"
null
was provided as value, but the field expects a list. If there are no associated entities, specify an empty list instead ([]
)"
Does this address the issue, and do you agree with the resolution?
Υes we agree. Indeed, a better error message would be very helpful. Thank you!
@Taniya-Das Would you be able to have a look at this? We just want the error message to be more user friendly, that's all.
I am unable to POST a Contact with a NULL location and/or telephone on a local branch of the v1.3.20240308 API. Both of these properties are not required to be filled per spec.
This POST results in a 422 Unprocessable Entity:
Response:
In contrast, this POST, with location and telephone properties omitted, is successful:
Response:
Of course, properties with NULL values can easily be stripped by the client before POST, so a workaround is possible, but on the other hand I was wondering why a NULL value is accepted for the "person" property (expecting an integer), but on the other hand its rejected as a location or telephone (both expecting arrays) -especially when the API seems to correctly interpret the NULL as "none".