Replies: 4 comments 13 replies
-
I agree with your proposed solution #1. |
Beta Was this translation helpful? Give feedback.
-
While I agree, in theory, with solution no. 1, I have to point out some things that are bothering me.
I believe we should consider a more compromise-based solution where we continue to send 200 OK responses if there is at least one valid source in the list of sources (with warnings for the bad sources), switching to 400 Bad Request only if all sources listed are invalid (and thus the user are receiving an unfiltered response). |
Beta Was this translation helpful? Give feedback.
-
A third option is to do nothing 🙂 I'm not trying to be fasecious, but this either affects no requests at all (e.g., very very low number of requests with the parameter ever have invalid values) or it affects some to a lot of requests. In either case, we can do nothing, and it will cause no long-term problem for our service stability. I've written more about my thought process in this comment: #3895 (reply in thread) I'd ask: why is this a problem, who does it affect, and considering it is a breaking change, under what precedence or philosophy of versioning are we accepting that compatibility change, and is it a precedence we're willing to take forward for non-critical issues that pose no issue to operational stability or security? Or does it actually present such an issue? Then we need to document that and prioritise the change accordingly. In any case, doing nothing is an option, unless there's a clear reason we need to break compatibility. |
Beta Was this translation helpful? Give feedback.
-
Closed along with the completion of #4030 |
Beta Was this translation helpful? Give feedback.
-
Problem
The current
source
field validation splits the value by a comma and filters this list by removing items that are not in the valid source name list for the media type. Then, the serializer joins all of the valid source names by comma and returns this string.So, when one of the items in the source list is invalid or misspelled, it is quietly dropped. Furthermore, the
source
value is ignored completely if there's a single misspelled value. So, https://api.openverse.engineering/v1/images/?source=flick ignores the source parameter and returns all of the images. This might be very confusing if the user has made a spelling mistake.Code validating the
source
field:openverse/api/api/serializers/media_serializers.py
Lines 651 to 658 in 520cd7a
Solutions
I think, we should return a 400 error if any of the source values is invalid, clearly showing which one it is, and also returning the list of valid sources. For instance, if the value is
source=flick,stocksnap
, instead of returning the images from the single valid source, "Stocksnap", we should return a 400 error saying something like "An invalid source "flick" in thesource
parameter. The list of valid sources for images: ....".@WordPress/openverse-api , do you agree this option is better than other alternatives?
We could also continue the current behavior if at least one of the sources is valid and return a 400 if the
source
parameter is present but contains no valid sources.Beta Was this translation helpful? Give feedback.
All reactions