Commit a6f07a3
authored
[Repo Assist] fix(rust-guard): remove dead .or_else() fallback in notifications arm (#8935)
🤖 *This is an automated pull request from Repo Assist.*
Closes #8921
## Root Cause
In `guards/github-guard/rust-guard/src/labels/response_items.rs`, the
`list_notifications | get_notification_details` arm had dead code:
```rust
let items = actual_response.as_array().or_else(|| response.as_array());
```
The `.or_else(|| response.as_array())` fallback is always a no-op
because `extract_mcp_response` (which produces `actual_response`)
returns either:
- **`Cow::Owned(parsed)`** – `parsed` was successfully deserialized from
`content[0].text`, so `actual_response.as_array()` is already `Some(_)`;
the fallback is unreachable.
- **`Cow::Borrowed(response)`** – `actual_response` *is* `response`, so
`.or_else(|| response.as_array())` checks the identical pointer twice.
This pattern is absent in every other arm of the same `match` block
(they all call `collect_items_simple(&actual_response)` or
`extract_items_slice(&actual_response, ...)` directly), making the
notifications arm inconsistently defensive without benefit.
## Fix
Remove the `.or_else(...)` chain, leaving the simpler:
```rust
let items = actual_response.as_array();
```
No behaviour change — the removed path was never executed.
## Tests Added
The notifications arm previously had **zero test coverage**. Three tests
are added:
| Test | Covers |
|------|--------|
| `list_notifications_labels_each_item_as_private` |
`private_user_label()` secrecy assignment for each notification |
| `list_notifications_description_includes_id` | `"notification:{id}"`
description format |
| `get_notification_details_empty_array_returns_empty` | empty array
input → empty result |
## Test Status
✅ **All 576 Rust tests pass** (up from 573 before adding the new tests):
```
test result: ok. 576 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.03s
```
1 file changed
Lines changed: 40 additions & 1 deletion
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | | - | |
| 395 | + | |
396 | 396 | | |
397 | 397 | | |
398 | 398 | | |
| |||
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
525 | 564 | | |
0 commit comments