Get rid of duplicate entries in the root resource's URI templates.

Review Request #12681 — Created Oct. 14, 2022 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

In Review Board 5.0, we introduced new top level reviews and comment resources
for querying across all review requests. These resources shared the same name
as other reviews and comment resources. This exposed a problem where resources
that have the same name will have their URI templates in the Root resource's
URI templates list overwritten by one another. Depending on the order that the
resources are added to the URI templates list, this can break the API by
replacing the URI template for a resource with another URI template that may
not behave in the same way or support the same methods as the previous one.

This is a problem that requires more thought and a rethink of how we handle
our resources in general, but for now this change applies a solution that
ensures we keep as much compatibility with our previous API (Python 2.7
behavior) as possible.

Instead of using the name attribute we use the uri_template_name and
uri_template_name_plural for the names of resources in the URI templates
list. This defaults to the name, but can be set to something else to avoid
duplicates in the templates list, or to None to have the resource omitted
from the templates list. Resources that share the same name had their
uri_template_name's changed to match how our previous API behaved and
to give access to the resources that were being overwritten.

  • Manually compared the URI templates list to our URI templates list from
    Python 2.7, made sure that the duplicate resources were renamed in a way that
    does not break compatibility with the Python 2.7 list.
  • Ran all unit tests.

Commits

Files