huridocs / uwazi

Uwazi is a web-based, open-source solution for building and sharing document collections
http://www.uwazi.io
MIT License
237 stars 79 forks source link

[IX] Fix or sanitize the response to be consistently arrays (or deal with single values) #6798

Closed konzz closed 3 months ago

konzz commented 4 months ago

We observed this issue while testing the changes. For two different extractors, both pointing to a select property the currentValue and the suggestedValue came some times as a plain string "value" and some times as an array ["value"]. Not clear how to reproduce this bug yet, @gabriel-piles might provide more context.

LaszloKecskes commented 3 months ago

While we were not able to reproduce the issue, after reviewing the code we found that the messages from the service were very lazily validated, and potentially something like this could slip through the cracks. It is unclear whether this was the case when the issue occurred, since this would assume a disagreement between the service and Uwazi.

The linked pull request will not be a fix, but will implement validation that will hopefully catch any unnoticed mismatches in the suggestion messages interfaces, that might cause problems.