GitHub.searchIssues silently drops 'incomplete_results: true' from search responses

Đang mở
#57 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
api

Hướng nghiên cứu

Start in src/prompt-generators/github/github.ts and trace the #query calls used by searchIssues, then run the minimal reproduction against the mocked GitHub response. Decide how the existing caller contract should surface incomplete_results and verify that a true flag on any page is no longer silent.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug S3

Observed behavior

The GitHub search API can respond with incomplete_results: true in its JSON body. From the GitHub docs:

The Search API has a maximum query timeout of 5 seconds and a maximum result set of 1000. The incomplete_results field will be true whenever a response is returned before the timeout completes, and indicates that some results may be missing.

GitHubSearchReply already types this field:

export interface GitHubSearchReply {
  readonly total_count: number;
  readonly incomplete_results?: boolean;
  readonly items: ReadonlyArray<GitHubIssue>;
}

However, GitHub.searchIssues in src/prompt-generators/github/github.ts never reads incomplete_results. When the field is true, the caller receives a ReadonlyArray<GitHubIssue> that silently omits matches, with no indication that the result is partial. The downstream GitHubPromptGenerator then yields prompts only for the partial set as if it were the full result. This matches the S1 description ("a consumer using the library according to its documented contract receives a result that is wrong, with no error or warning to indicate the problem") at the boundary, but in practice the failure mode is intermittent and recovers on retry, so it is in S3 territory.

Expected behavior

searchIssues should surface incomplete_results: true to the caller in some form. Reasonable options:

  • Log a warning to stderr when the flag is observed on any page, similar to logQuery.
  • Throw an error, requiring the caller to opt in to incomplete results.
  • Return a richer result object ({ issues, incomplete }) instead of a bare array.

A console warning is the lowest-friction fix and matches the existing logging style; an opt-in flag (for example, allowIncomplete) would be more rigorous and avoid silent partial results by default.

Minimal reproduction

import { GitHub } from 'loop-the-loop/prompt-generators/github/github';
import { vi } from 'vitest';

vi.stubGlobal(
  'fetch',
  vi.fn().mockResolvedValue({
    ok: true,
    status: 200,
    text: () =>
      Promise.resolve(
        JSON.stringify({
          total_count: 12345,
          incomplete_results: true,
          items: [
            { number: 1, title: 't', html_url: 'https://github.test/1', state: 'open' },
          ],
        }),
      ),
  }),
);

const github = new GitHub({ origin: 'https://api.test' });
const issues = await github.searchIssues({
  repository: 'octocat/Hello-World',
  query: 'is:open',
  perPage: 1,
  maxResults: 1,
});
// issues.length === 1, but the caller has no way to know the search was
// truncated by GitHub's 5-second timeout.

Suggested fix

At minimum, in src/prompt-generators/github/github.ts, check reply.incomplete_results after each #query call and emit a console.warn (or expose the flag through the return type). For example:

if (reply.incomplete_results) {
  console.warn(
    `GitHub search returned incomplete results for query: ${buildIssueSearchQuery(params)}`,
  );
}
Ngôn ngữ chính
TypeScript
Star
2
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của joewalker/loop-the-loop

Tất cả issue của joewalker/loop-the-loop

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.