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
Conversation
…ove comments that would be collapsed in the web UI unless explicitly asking for them
dklawren
requested review from
Xzzz and
cgsheeh
and
a balanced review from Copilot
September 4, 2026 17:32
There was a problem hiding this comment.
🟡 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_commentsopt-in filtering. - Exposes the
collapsedcomment 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::collapseddoes 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=commentsstill 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 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.