Skip to content

Commit cb10efb

Browse files
betegoncodex
andcommitted
refactor(cli): keep short ID results paired with their org
Return the organization with each lookup result so collection no longer depends on parallel array indices. Co-Authored-By: GPT-6 <noreply@openai.com>
1 parent 61f2ace commit cb10efb

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

‎packages/cli/src/commands/issue/utils.ts‎

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -343,24 +343,16 @@ async function findIssuesByShortId(
343343
const results = await Promise.all(
344344
orgSlugs.map((org) =>
345345
limit(() =>
346-
withAuthGuard(() =>
347-
tryGetIssueByShortId(org, fullShortId, {
346+
withAuthGuard(async () => {
347+
const issue = await tryGetIssueByShortId(org, fullShortId, {
348348
collapse: ISSUE_DETAIL_COLLAPSE,
349-
})
350-
)
349+
});
350+
return issue ? { org, issue } : null;
351+
})
351352
)
352353
)
353354
);
354355

355-
const successes: StrictResolvedIssue[] = [];
356-
for (let i = 0; i < results.length; i++) {
357-
const result = results[i];
358-
const org = orgSlugs[i];
359-
if (result && org && result.ok && result.value) {
360-
successes.push({ org, issue: result.value });
361-
}
362-
}
363-
364356
// If every org failed with a real error (403, 5xx, network timeout),
365357
// surface it instead of falling through to a misleading "not found".
366358
// Only throw when ALL results are errors — if some orgs returned clean
@@ -376,7 +368,9 @@ async function findIssuesByShortId(
376368
}
377369
}
378370

379-
return successes;
371+
return results.flatMap((result) =>
372+
result.ok && result.value ? [result.value] : []
373+
);
380374
}
381375

382376
/**

0 commit comments

Comments
 (0)