github-types.ts: GitHubIssue.repository field is declared but never populated by the search API

Open Beginner friendly
#53 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
86/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
api

Research direction

Start by reading src/prompt-generators/github/github-types.ts and src/prompt-generators/github/github.ts, then confirm with a repository-wide search that GitHubRepository is unused and searchIssues calls only /search/issues. Remove the inaccurate unused repository types, or replace the field with repository_url as supported by the issue; done means the types match the endpoint and the project still type-checks.

Written by the indexing model from the issue text.

Description

bug S4

Observed behavior

GitHubIssue in src/prompt-generators/github/github-types.ts declares an optional nested repository object:

export interface GitHubIssue {
  // ...
  readonly repository?: GitHubRepository;
  readonly [key: string]: unknown;
}

export interface GitHubRepository {
  readonly full_name: string;
  readonly name?: string;
  readonly owner?: GitHubUser;
  readonly [key: string]: unknown;
}

But the only endpoint the client actually calls is GET /search/issues (see GitHub.searchIssues in src/prompt-generators/github/github.ts). GitHub's /search/issues response does not include a nested repository object on issue items. It includes repository_url (a string URL). So issue.repository is always undefined at runtime for this code path.

A Grep over the repo confirms GitHubRepository is declared but never consumed:

src/prompt-generators/github/github-types.ts:106:  readonly repository?: GitHubRepository;
src/prompt-generators/github/github-types.ts:125:export interface GitHubRepository {

Expected behavior

Either:

  1. Remove the repository?: GitHubRepository field (and the unused GitHubRepository interface) from github-types.ts so the type only documents fields the /search/issues response actually returns; or
  2. Replace it with the field that actually is returned, repository_url?: string, matching what GitHub sends.

Minimal reproduction

Read src/prompt-generators/github/github-types.ts and src/prompt-generators/github/github.ts; only GET /search/issues is called; the search response does not contain a nested repository object. A code reader who sees the type will reasonably assume that, for example, issue.repository?.full_name is meaningful, but it is always undefined.

Suggested fix

Drop repository?: GitHubRepository from GitHubIssue and delete the GitHubRepository interface, since nothing reads either of them. If a future code path starts using a different endpoint (e.g. /issues or /repos/{owner}/{repo}/issues) that does return a repository object, re-introduce a more accurate type at that point.

Dominant language
TypeScript
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from joewalker/loop-the-loop

All issues in joewalker/loop-the-loop

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.