Skip to content

Bug 2095730 - Fix small issues in the MyDashboard, Review and BugModal API endpoints - #2841

Merged
dklawren merged 9 commits into
mozilla:masterfrom
Xzzz:bug-2095730
Nov 24, 2026
Merged

dklawren merged 9 commits into
mozilla:masterfrom
Xzzz:bug-2095730

Conversation

@Xzzz

@Xzzz Xzzz commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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

  • MyDashboard run_last_changes:
    • returns the latest comment since changeddate_api, not any of them (usually the oldest)
    • finds it when the bug is given by its alias
    • renders it as Markdown only when the comment is a Markdown one
  • Review flag_activity: a search without any criteria is refused with flag_activity_parameters_required, instead of returning all the activity of the last 30 days. The docs mention it.
  • BugModal product_info and new_product: more than one product is refused, instead of using the last one.

Test plan

  • My Dashboard: expand a bug row whose last changes include several comments: the latest one is shown, rendered as Markdown only if it was written in Markdown
  • GET /rest/review/flag_activity with no parameter: 400 flag_activity_parameters_required
  • GET /rest/bug_modal/product_info?product=Firefox&product=Core: error

References

Xzzz added 5 commits November 24, 2026 19:04
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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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() }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 94e80c0, see the thread just below.

Comment thread extensions/Review/t/bmo/review-api.t Outdated
->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'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Xzzz added 3 commits November 24, 2026 20:34
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.
@dklawren
dklawren merged commit 76ec7f0 into mozilla:master Nov 24, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants