Skip to content

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

Open
Xzzz wants to merge 1 commit into
mozilla:masterfrom
Xzzz:bug-2081859
Open

Xzzz wants to merge 1 commit 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

# 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

This branch has not been deployed

No deployments
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