Repository navigation
Bug 2095730 - Fix small issues in the MyDashboard, Review and BugModal API endpoints - #2841
Conversation
The last comment query had LIMIT 1 but no ORDER BY, so it returned any comment after changeddate_api, usually the oldest one. Order by date and comment id, newest first.
…Dashboard run_last_changes The last comment query was bound to the bug_id param as given, so with a bug alias it looked for bug_id = '<alias>' and never found a comment. Bind the id of the bug it already loaded.
…d run_last_changes With use_markdown on, every last comment was rendered as Markdown, including plain text ones, which then showed formatting they never had. Check the comment's is_markdown flag too, as EditComments does.
The flag_activity_parameters_required check ran after the date range was added to the match criteria, so it never fired, and a request with no criteria returned the whole table for the last 30 days. Run it before the date range, limit and offset are added.
…nd new_product The legacy REST layer passed a repeated ?product= as a list, which product_info refused. Mojo keeps only the last value, so that check, also added to new_product in the migration, never fired and the request silently used the last product. Read product as a list param and refuse more than one value
There was a problem hiding this comment.
🟡 Changes recommended
The test cleanup can persist an undefined Markdown setting, and the new fixtures can disrupt query ordering and cause timing-dependent assertion failures.
2 open issues
What changed in this PR
Fixes five pre-existing issues in the MyDashboard, Review, and BugModal API endpoints following their migration to native Mojo controllers.
Changes:
- MyDashboard returns the latest comment, supports bug aliases, and respects each comment’s Markdown setting.
- Review rejects flag-activity requests without search criteria and documents the requirement.
- BugModal rejects multiple product values; regression tests cover the endpoint fixes.
| File | Description |
|---|---|
| extensions/Review/t/bmo/review-api.t | Tests rejection of requests without search criteria. |
| extensions/Review/lib/API/V1/Review.pm | Checks search criteria before adding date and pagination filters. |
| extensions/MyDashboard/t/bmo/mydashboard-api.t | Tests latest-comment selection, aliases, and plain-text rendering. |
| extensions/MyDashboard/lib/API/V1/MyDashboard.pm | Corrects comment selection, bug lookup, and rendering. |
| extensions/BugModal/t/bmo/bug-modal-api.t | Tests rejection of multiple product values. |
| extensions/BugModal/lib/API/V1/BugModal.pm | Validates product parameter cardinality in both endpoints. |
| docs/en/md/api/core/v1/flag-activity.md | Documents required search criteria and the resulting error. |
Review effort: Balanced
| # Markdown is only used for comments written in Markdown. The app reads params | ||
| # from the database, so set it there, and put it back afterwards. | ||
| my $use_markdown = Bugzilla->params->{use_markdown}; | ||
| END { SetParam('use_markdown', $use_markdown); write_params() } |
There was a problem hiding this comment.
Fixed in 94e80c0, see the thread just below.
| ->json_hasnt('/error', 'an empty requestee is ignored, not a 404'); | ||
| $t->get_ok('/rest/review/flag_activity/requestee/')->json_like( | ||
| '/message' => qr/without any search terms/, | ||
| 'an empty requestee is ignored, not a 404' |
There was a problem hiding this comment.
test name still says the empty requestee is ignored, but it now checks that it's refused. maybe 'an empty requestee alone is refused'
also the old status_is(200) was dropped with nothing in its place. adding ->status_is(400) here and on the limit/date request below would catch a 500 with the same message
There was a problem hiding this comment.
Thanks! :)
Fixed in 4c0fa22: renamed to "an empty requestee alone is refused", and both requests now check for a 400. Against the old Review.pm, both status checks fail as expected.
| # Markdown is only used for comments written in Markdown. The app reads params | ||
| # from the database, so set it there, and put it back afterwards. | ||
| my $use_markdown = Bugzilla->params->{use_markdown}; | ||
| END { SetParam('use_markdown', $use_markdown); write_params() } |
There was a problem hiding this comment.
the END block is registered at compile time, so if the test dies before line 189 $use_markdown is still undef and this writes use_markdown = undef to the shared test db. later test_bmo suites would then run with markdown off. guard it with if defined $use_markdown
There was a problem hiding this comment.
Thanks, well spotted! :)
=> Fixed in 94e80c0: the END block now only restores it when $use_markdown is defined. Checked by making the test die before that line: use_markdown was wiped before, it keeps its value now.
The two bugs added for run_last_changes were assigned to the test user, so they also came back in its assignedbugs query, sorted by last change, newest first. Created a second later than the first bug, either one would come first there and fail the check that the first bug is listed first. Assign them to the admin, as the hidden bug already is.
…est has read it The END block that puts use_markdown back is registered at compile time, so it also ran when the test skipped or died before reading it, and then wrote an empty use_markdown to the shared test database, turning Markdown off for the test files run after it. Only restore it once it was read.
…vity searches The empty requestee test kept its old name, which said it was ignored while it now checks that it is refused, and neither refused search checked its status, so a 500 with the same message would have passed. Rename it and expect a 400 on both.

Summary
Fixes five small issues in the MyDashboard, Review and BugModal API endpoints, one commit each.
Found while working on #2836 (2094122), they predate the migration to native Mojo controllers.
Changes
run_last_changes:changeddate_api, not any of them (usually the oldest)flag_activity: a search without any criteria is refused withflag_activity_parameters_required, instead of returning all the activity of the last 30 days. The docs mention it.product_infoandnew_product: more than oneproductis refused, instead of using the last one.Test plan
GET /rest/review/flag_activitywith no parameter: 400flag_activity_parameters_requiredGET /rest/bug_modal/product_info?product=Firefox&product=Core: errorReferences