Skip to content

Bug 2069143 - When retrieving comments for a bug(s) via REST API, remove comments that would be collapsed in the web UI unless explicitly asking for them - #2736

Open
dklawren wants to merge 2 commits into
mozilla:masterfrom
dklawren:2069143

Conversation

@dklawren

@dklawren dklawren commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

…ove comments that would be collapsed in the web UI unless explicitly asking for them
@dklawren
dklawren requested review from Xzzz and cgsheeh and a balanced review from Copilot September 4, 2026 17:32

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 filtering misses Treeherder comments that BugModal collapses independently of tags, and one changed API path lacks coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Filters collapsed comments from REST responses unless explicitly requested.

Changes:

  • Adds _collapsed_comments opt-in filtering.
  • Exposes the collapsed comment field.
  • Adds REST tests and documentation.
File summaries
File Description
Bugzilla/WebService/Bug.pm Implements filtering and serialization.
qa/t/rest_bug_comments.t Tests collapsed-comment retrieval.
docs/en/rst/api/core/v1/comment.rst Documents comment API behavior.
docs/en/rst/api/core/v1/bug.rst Documents embedded comment filtering.
Review details

Suppressed comments (1)

Bugzilla/WebService/Bug.pm:1697

  • The embedded-comments path has the same gap as comments(): Comment::collapsed does not include BugModal's author-based collapse rule for Treeherder users (extensions/BugModal/lib/ActivityStream.pm:170-189). As a result, GET /rest/bug?...include_fields=comments still returns untagged comments that the web UI collapses by default. Reuse a shared collapse predicate here so both API paths match the UI.
      next if $comment->collapsed && !$want_collapsed;
  • Files reviewed: 4/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

my @result;
foreach my $comment (@$comments) {
next if $comment->is_private && !$user->is_insider;
next if $comment->collapsed && !$want_collapsed;
Comment thread qa/t/rest_bug_comments.t
Comment on lines +225 to +232
$t->get_ok($bug_comment_path
. '?include_fields=_default,_collapsed_comments' => api_headers($admin_key))
->status_is(200);
my ($spam_comment)
= grep { $_->{id} == $spam_id } map { @{$_->{comments}} }
values %{$t->tx->res->json->{bugs}};
ok($spam_comment, 'collapsed comment is returned with _collapsed_comments');
ok($spam_comment->{collapsed}, 'collapsed comment is flagged as collapsed');
…::collapsed

Move BugModal's treeherder-author collapse rule into Bugzilla::Comment::collapsed
so every caller (the REST API included) agrees with the web UI, and add test
coverage for the _bug_to_hash comment path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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