Skip to content

Commit 9ede219

Browse files
unhappychoiceclaude
andcommitted
fix(fetcher): pin github::items::render_items as sync-only
`render_items` is a public sync helper still called by `good_first_issues`, whose `shapes()` set is bounded to the four sync-renderable variants. Routing `Badge` or `ImageLinkedList` through it would silently degrade `Badge` to the `TextBlock` fallback (no count, no noun) and emit `ImageLinkedList` with every thumbnail column blank. Document the contract and `debug_assert` on both shapes so accidental misuse crashes loudly in tests instead of shipping broken bodies. Fetchers that accept those shapes already route through `forge_items::dispatch_rows_async`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent a15b6dd commit 9ede219

1 file changed

Lines changed: 29 additions & 15 deletions

File tree

‎src/fetcher/github/items.rs‎

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,21 @@ pub fn repo_from_url(url: &str) -> Option<RepoSlug> {
5454
RepoSlug::parse(rest)
5555
}
5656

57-
/// Renders issue / PR items via the shared forge-row pipeline. When `include_repo` is true,
58-
/// each label is prefixed with `owner/name#42` — used by user-scope fetchers whose results span
59-
/// many repos. Per-repo fetchers pass `false` so the row stays at `#42`.
57+
/// Sync-only path for fetchers whose `shapes()` set doesn't include `Badge` /
58+
/// `ImageLinkedList` (currently `good_first_issues`). Both of those variants need
59+
/// preprocessing that this signature can't reach: `Badge` needs the row count + a noun pair
60+
/// for `forge_items::render_count_badge`, and `ImageLinkedList` needs avatar URLs resolved
61+
/// through `thumbnails::download_many` before render. Fetchers that accept those shapes go
62+
/// through `forge_items::dispatch_rows_async` instead.
63+
///
64+
/// When `include_repo` is true, each label is prefixed with `owner/name#42` (used by
65+
/// user-scope fetchers whose results span many repos). Per-repo fetchers pass `false` so the
66+
/// row stays at `#42`.
6067
pub fn render_items(items: &[IssueItem], shape: Shape, include_repo: bool) -> Body {
68+
debug_assert!(
69+
!matches!(shape, Shape::Badge | Shape::ImageLinkedList),
70+
"render_items is sync-only; route {shape:?} through forge_items::dispatch_rows_async"
71+
);
6172
let rows = to_forge_rows(items, include_repo);
6273
forge_items::render_forge_rows(&rows, shape)
6374
}
@@ -294,18 +305,21 @@ mod tests {
294305
}
295306

296307
#[test]
297-
fn render_image_linked_carries_empty_thumbnail_until_resolved() {
298-
// The fetcher is responsible for resolving `avatar_url` -> `avatar_path` via the
299-
// shared thumbnails downloader before reaching the renderer. Calling `render_items`
300-
// directly leaves the column blank — verifies the unresolved path still produces a
301-
// structurally valid body rather than crashing.
302-
let Body::ImageLinkedList(data) =
303-
render_items(&[issue_item()], Shape::ImageLinkedList, true)
304-
else {
305-
panic!("expected image linked list");
306-
};
307-
assert_eq!(data.items.len(), 1);
308-
assert!(data.items[0].thumbnail_path.is_none());
308+
#[should_panic(expected = "render_items is sync-only")]
309+
fn render_items_rejects_image_linked_list_in_debug() {
310+
// `ImageLinkedList` needs avatar resolution through the async thumbnails downloader,
311+
// so the sync helper refuses it rather than silently emitting a row with a blank
312+
// thumbnail column. Fetchers accepting that shape route through
313+
// `forge_items::dispatch_rows_async` instead.
314+
let _ = render_items(&[issue_item()], Shape::ImageLinkedList, true);
315+
}
316+
317+
#[test]
318+
#[should_panic(expected = "render_items is sync-only")]
319+
fn render_items_rejects_badge_in_debug() {
320+
// Same reasoning for `Badge`: it needs the row count + a noun pair, neither of which
321+
// are reachable through this signature.
322+
let _ = render_items(&[issue_item()], Shape::Badge, false);
309323
}
310324

311325
#[test]

0 commit comments

Comments
 (0)