-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for edge cases in the /related
endpoint
#3188
Comments
The problem we had in those cases was that when the value for some field is For instance, when the So, I think there are 2 ways of solving this:
What do you think, @WordPress/openverse-maintainers , which approach would be preferable? Footnotes |
I would prefer option 2, it makes it more explicit on the API side that we know a value could be absent on the |
No strong opinion here, but to give support for option 1, it creates a consistent API, and doesn't require us to "remember" that title could not exist. It's a bit easier to type as well, if we decided to encode
This sounds nice to me, but I don't know how we would enforce it. We don't have type checking, which would allow us to at least force a check for None. If there's a way to actually allow dot-access for some and not for others, that would be great, but non-obvious conventions and "ambient knowledge" of a niche API is very easy to forget and to introduce a new bug. The most ideal answer is for all our code paths to get tested with real data for all possible edge cases. That way it just does not matter what approach we take in the code, it will have to handle it one way or another. Making it easy/"the default way" for tests to run against data with known edge cases would go a long way to solve this, regardless of the convention or change in API. |
I would love to have these tests, but I'm afraid it's really difficult because we don't know what we don't know, and there might be edge cases that we are not aware of. |
I like option 2, which is more or less what we're already doing, but regardless of said options, I also think that is not a substitute for testing, as Sara said. That is the main goal of this ticket.
We know these fields are optional, it is our "business model" so it must be kept in mind for these type of code decisions. I'm not sure what other unknowns you're referring but it is part of the purpose of automated testing to reduce that uncertainty. |
Sorry for hijacking this issue, @krysal! So, we can say that in this issue, we should add unit tests when the main media items does not some properties, and the
When writing the PR for related endpoint, I knew that some items don't have title, creator or tags. However, I did not know that the |
Current Situation
In #3177 and #3181, we issued quick hotfixes to solve errors when trying to access related works from a media without a defined
title
orcreator
. These could have been caught with automated tests.Suggested Improvement
We want to include some unit tests to prevent this situation from happening in the future, just in case.
Benefit
Prevent more errors when calling for the
/related
endpoint.Additional context
Mentioned links in the beginning. Check those to see the reproduction steps before the issues were fixed.
The text was updated successfully, but these errors were encountered: