flake8
-
reviewboard/webapi/resources/root.py (Diff revision 1) Show all issues
Review Request #12726 — Created Nov. 16, 2022 and submitted
Information | |
---|---|
chipx86 | |
Review Board | |
release-5.0.x | |
Reviewers | |
reviewboard | |
We recently had some conflicts with the new root resources for reviews
and comments, and added collision detection for URI template
registrations.Since these went in, a couple regressions were discovered:
The root review/comment APIs had registered item APIs, which don't
actually work, due to the lack ofuri_object_key = None
.The root diff comment API had the wrong URL
(/api/review-diff-comment/
instead of/api/diff-comments
/) and
URI template (review_diff_comment
instead ofall_diff_comments
).The review request file attachment comments API mistakenly had a
all_reviews_file_attachment_comments
URI template, which doesn't
represent that resource.Some of the URI templates were pointing to the wrong API resources,
based on a comparison to the Review Board 3 API on RBCommons.Some of these were just wrong resources or attributes being set, which
regressed in 5.0.1. However, most of this is just due to the shaky
foundation that URI templates have historically been on. We didn't have
proper management of any of this, and any kind of testing is brand-new.
So a big part of this change is simply an audit of the URI templates.To address the problems we've hit, we're now deprecating the older
confusing URI templates that triggered collisions before, and are
instead replacing them with namespaced versions. These are all ones that
pertain to diffs, reviews, review replies, and review requests.The complete list of URI templates have been added to the
RootResource
documentation, as have the legacy names. These are versioned (starting
with 4.0) to help users and us.All legacy names are now considered deprecated, but will still point to
the old locations pertaining to the Review Board 3 API.Legacy URI templates are also registered in a way that doesn't create
an entry per API root resource location, which will save memory for
installs using Local Sites.
Unit tests pass.
Diffed the list against the 5.0.1 and 3.0.x releases to verify
that the resulting URI templates seem to be compatible with what we
intended before and what we're wanting to point to now, and that
all legacy URLs correctly match.Built the docs and checked that the resulting Root Resource's docs
on URI templates correctly linked to each target resource page.
Summary | |
---|---|
Description | From | Last Updated |
---|---|---|
I went through the resources that exist in our expected_uri_templates reference and found some that are missing from the RootResource … |
![]() |
|
'typing.Dict' imported but unused Column: 1 Error code: F401 |
![]() |
|
I'm thinking maybe file_diff would be a better name? Since it matches the policy_id here and would follow the URI … |
![]() |
|
Should move this one to the deprecated section since you're replacing it with review_request_draft. |
![]() |
|
This key should be extensions instead of extension-list. |
![]() |
|
These were actually added in 5.0.1. |
![]() |
|
I think it could be worthwhile to add comments here to show which URI templates and names are legacy/deprecated. Or … |
![]() |
|
review_request_draft will be added in 5.0.2. |
![]() |
Removed an unused import.
Description: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commits: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Diff: |
Revision 2 (+1558 -120) |
Good stuff, thanks for doing this! Really helps to clear things up with the URI templates while keeping legacy behaviour. And good catch for the root reviews/comments fixes.
I went through the resources that exist in our
expected_uri_templates
reference and found some that are missing from theRootResource
documentation:
Resource | URI template name
---------|-------------------
File Diff Comment List | file_diff_comments
Diff Context | diff_context
File Attachment | file_attachment
File Attachment List | file_attachments
reviewboard/webapi/resources/filediff.py (Diff revision 2) |
---|
I'm thinking maybe
file_diff
would be a better name? Since it matches thepolicy_id
here and would follow the URI naming for theFileDiffCommentResource
(which I set tofile_diff_comment
in 5.0.1). Or you could change theFileDiffCommentResource
URI name todiff_file_comment
.
reviewboard/webapi/resources/root.py (Diff revision 2) |
---|
This key should be
extensions
instead ofextension-list
.
reviewboard/webapi/tests/test_root.py (Diff revision 2) |
---|
I think it could be worthwhile to add comments here to show which URI templates and names are legacy/deprecated. Or move them so that they have their own section in the dict, like how you did it in the
RootResource
documentation. But then again we could always just refer to the documentation for this info.
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 3 (+1874 -352) |
reviewboard/webapi/resources/root.py (Diff revisions 2 - 3) |
---|
Should move this one to the deprecated section since you're replacing it with
review_request_draft
.
reviewboard/webapi/tests/test_root.py (Diff revisions 2 - 3) |
---|
review_request_draft
will be added in 5.0.2.
Updated deprecation info for
draft
vs.review_request_draft
.
Commits: |
|
|||||||||
---|---|---|---|---|---|---|---|---|---|---|
Diff: |
Revision 4 (+1876 -352) |