[Repo Assist] fix(rust-guard): remove dead .or_else() fallback in notifications arm#8935
Merged
lpcox merged 2 commits intoJul 8, 2026
Conversation
The `.or_else(|| response.as_array())` on line 395 of response_items.rs
was always a no-op because `extract_mcp_response` returns either:
- `Cow::Owned(parsed)`: parsing succeeded, so `actual_response.as_array()`
is already the result — the fallback is unreachable.
- `Cow::Borrowed(response)`: `actual_response` IS `response`, so the
fallback checks the identical value twice.
This removes the dead fallback and makes the notifications arm consistent
with every other arm in the file (all of which use `actual_response`
directly, without a `response` fallback).
Adds three tests that previously had zero coverage for this arm:
- list_notifications_labels_each_item_as_private: verifies the
private_user_label() secrecy assignment for each notification.
- list_notifications_description_includes_id: verifies the
"notification:{id}" description format.
- get_notification_details_empty_array_returns_empty: verifies an
empty array input produces no labeled items.
All 576 Rust tests pass after this change (was 573 before adding tests).
Closes #8921
🤖 Generated by Repo Assist
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR simplifies Rust Guard item-labeling for GitHub notifications by removing an unreachable .or_else() fallback and adds targeted unit tests to cover the previously untested notifications arm in label_response_items.
Changes:
- Remove dead
.or_else(|| response.as_array())fallback in the notifications match arm. - Add unit tests covering notification secrecy labeling, description formatting, and empty-array behavior.
Show a summary per file
| File | Description |
|---|---|
| guards/github-guard/rust-guard/src/labels/response_items.rs | Removes unreachable fallback logic in notifications handling and adds new tests for notification labeling behavior. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This was referenced Jul 8, 2026
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.
🤖 This is an automated pull request from Repo Assist.
Closes #8921
Root Cause
In
guards/github-guard/rust-guard/src/labels/response_items.rs, thelist_notifications | get_notification_detailsarm had dead code:The
.or_else(|| response.as_array())fallback is always a no-op becauseextract_mcp_response(which producesactual_response) returns either:Cow::Owned(parsed)–parsedwas successfully deserialized fromcontent[0].text, soactual_response.as_array()is alreadySome(_); the fallback is unreachable.Cow::Borrowed(response)–actual_responseisresponse, so.or_else(|| response.as_array())checks the identical pointer twice.This pattern is absent in every other arm of the same
matchblock (they all callcollect_items_simple(&actual_response)orextract_items_slice(&actual_response, ...)directly), making the notifications arm inconsistently defensive without benefit.Fix
Remove the
.or_else(...)chain, leaving the simpler:No behaviour change — the removed path was never executed.
Tests Added
The notifications arm previously had zero test coverage. Three tests are added:
list_notifications_labels_each_item_as_privateprivate_user_label()secrecy assignment for each notificationlist_notifications_description_includes_id"notification:{id}"description formatget_notification_details_empty_array_returns_emptyTest Status
✅ All 576 Rust tests pass (up from 573 before adding the new tests):
proxy.golang.orgis inaccessible). This is a Rust-only change.Generated by Repo Assist
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
awmgmcpgproxy.golang.orgSee Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run