MCPcopy Create free account
hub / github.com/TanStack/ai / fetchIssue

Function fetchIssue

examples/ts-react-chat/src/sandbox-triage.ts:285–321  ·  view source on GitHub ↗
(
  repo: string,
  issueNumber: number,
)

Source from the content-addressed store, hash-verified

283
284/** Fetch one issue. Uses GITHUB_TOKEN when set (private repos / rate limits). */
285export async function fetchIssue(
286 repo: string,
287 issueNumber: number,
288): Promise<GitHubIssue> {
289 const headers: Record<string, string> = {
290 Accept: 'application/vnd.github+json',
291 'User-Agent': 'tanstack-ai-sandbox-triage',
292 }
293 if (process.env.GITHUB_TOKEN) {
294 headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`
295 }
296 const res = await fetch(
297 `https://api.github.com/repos/${repo}/issues/${issueNumber}`,
298 { headers },
299 )
300 if (!res.ok) {
301 throw new Error(
302 `GitHub API ${res.status} ${res.statusText}: ${await res.text()}`,
303 )
304 }
305 const issue = (await res.json()) as {
306 number: number
307 title: string
308 body: string | null
309 html_url: string
310 pull_request?: unknown
311 }
312 if (issue.pull_request !== undefined) {
313 throw new Error(`${repo}#${issueNumber} is a pull request, not an issue.`)
314 }
315 return {
316 number: issue.number,
317 title: issue.title,
318 body: issue.body ?? '',
319 url: issue.html_url,
320 }
321}
322
323export function buildTriagePrompt(issue: GitHubIssue, repo: string): string {
324 return [

Callers 1

triagePostFunction · 0.85

Calls 3

jsonMethod · 0.80
textMethod · 0.65
fetchFunction · 0.50

Tested by

no test coverage detected