Skip to content

Bug 2081859 - Migrate Bug REST resource to native Mojo API: comments (comments, add_comment, render_comment, reactions, tags) - #2787

Merged
dklawren merged 5 commits into
mozilla:masterfrom
Xzzz:bug-2081859
Oct 21, 2026
Merged

dklawren merged 5 commits into
mozilla:masterfrom
Xzzz:bug-2081859

Conversation

@Xzzz

@Xzzz Xzzz commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Ports the comment methods of Bugzilla::WebService::Bug (comments, add_comment, render_comment, get_comment_reactions, update_comment_reactions, update_comment_tags, search_comment_tags) into a native Bugzilla::API::V1::BugComment Mojo controller, following the earlier migrations in this series.

Third of the four sub-bugs of 2081819. The rest of the legacy Bug module stays until 2081860.

Changes

  • Add Bugzilla/API/V1/BugComment.pm, with the same responses as the legacy endpoints:
    • GET / POST /rest/bug/<id>/comment
    • GET /rest/bug/comment/<comment_id>
    • GET / PUT /rest/bug/comment/<comment_id>/reactions
    • PUT /rest/bug/comment/<comment_id>/tags
    • GET /rest/bug/comment/tags/<query>
    • POST /rest/bug/comment/render
    • OPTIONS on each of them
  • Remove the seven methods and their POD from Bugzilla/WebService/Bug.pm, and their routes from Resources/Bug.pm. The comment helpers stay there for the comments field of bug get/search until 2081860.
  • MyDashboard: run_last_changes called the legacy comments() through inheritance; it now loads the comment directly (same output).
  • Kept from the legacy server:
    • new_since converted to the database timezone, skip_private, _collapsed_comments, edit counts.
    • Anonymous GETs are rate-limited.
    • A path id is added to the query ids on GET; on POST/PUT, values from the body or query string win over the path.
  • Tests: new qa/t/rest_bug_comment_misc.t (render, tag search, query parameters, OPTIONS).

Behaviour changes

  • A bug id sent as an object to add_comment or render_comment is rejected with invalid_params, instead of reaching Bugzilla::Bug->check() as object conditions.
  • With disable_bug_updates on, add_comment returns a JSON error. The legacy REST server returned the HTML "updates disabled" page.
  • add, remove and comment_tags sent once in the query string or a form body are treated as a list (they used to cause a 500).

Not carried over: ETag/304 and JSONP callback=, as in the other migrated V1 modules.

Merge order: please merge after #2785 and #2786. All three remove code from Bugzilla/WebService/Bug.pm and Resources/Bug.pm; this branch will be updated with master once they have landed.

Test plan

  • GET /rest/bug/<id>/comment logged out and logged in, with new_since, skip_private and include_fields=_default,_collapsed_comments
  • GET /rest/bug/comment/<id>?comment_ids=<other> returns both
  • POST /rest/bug/<id>/comment with comment_tags, expecting 201
  • POST /rest/bug/<id>/comment with an object id, expecting invalid_params
  • PUT / GET /rest/bug/comment/<id>/reactions
  • PUT /rest/bug/comment/<id>/tags, then GET /rest/bug/comment/tags/<query>
  • POST /rest/bug/comment/render
  • OPTIONS on each path
  • Bug modal: add a comment, react, tag a comment, preview a comment; My Dashboard "last changes"

References

…(comments, add_comment, render_comment, reactions, tags)
@Xzzz
Xzzz requested review from dklawren and kyoshino October 15, 2026 20:00
Comment thread Bugzilla/API/V1/BugComment.pm Outdated

# A bug id is a single value. A hash here would reach Bugzilla::Bug->check()
# as a set of object conditions. (A comment_id hash fails detaint_natural.)
return (undef, 'invalid_params') if ref $params->{id};

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.

pass a type_error with invalid_params (e.g. "id must be a single value") so the message isn't cut off

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.

The message now reads "API method received invalid params: id must be a single value", checked in rest_bug_comment_misc.t

Done in 1bf81ec

Xzzz added 4 commits October 20, 2026 17:00
Pass a type_error with invalid_params so the message reads "API method received
invalid params: id must be a single value" instead of stopping after the colon.
…er_comment

Bug 2079840 added the hook to the legacy Bug.render_comment, which this branch removes.
Without it, the comment preview no longer lists who a @mention will CC and needinfo.
@Xzzz
Xzzz requested a review from dklawren October 20, 2026 17:34
@dklawren
dklawren merged commit 3684c16 into mozilla:master Oct 21, 2026
8 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.

2 participants