Skip to content

fix(backend): a plain 403 must not abort the rest of evidence collection (#621) - #640

Closed
Yuncan050115 wants to merge 2 commits into
FindAny:mainfrom
Yuncan050115:fix/hydrate-evidence-plain-403
Closed

Yuncan050115 wants to merge 2 commits into
FindAny:mainfrom
Yuncan050115:fix/hydrate-evidence-plain-403

Conversation

@Yuncan050115

@Yuncan050115 Yuncan050115 commented Nov 4, 2026 •

Copy link
Copy Markdown

Refs #621.

Summary

  • use errors.Is for the wrapped ErrGitHubUnavailable in hydrateTopRepoEvidence, so a plain 403 skips one repository instead of aborting every later candidate
  • keep rate-limit (remaining=0 / 429), cancellation and the unwrapped 404 path behaving exactly as before
  • add httptest coverage for both the README and the languages branch, plus a five-class response table

One README 403 previously ended the candidate loop while finishCollectedScan discarded the error and the scan still reported complete_public. The second-pass merge that erases first-pass evidence is deliberately not in this PR (#645).

Verification

  • go test ./internal/backend/ -run '^TestHydrateTopRepoEvidence' -count=1: 4 tests + 5 subtests pass. With github_enrichment.go reverted to main, the two continue-cases and the two skip-class subtests fail and the three abort-cases still pass; green with the fix.
  • go vet ./internal/backend/, go build ./internal/backend/, gofmt -l: clean.
  • node ops/open-core/split.mjs check: 2292 files classified, 0 public->private references; blockers: 0.

Package-wide go test ./internal/backend/ keeps a failure set identical to baseline (sorted-name diff empty both ways) — no C compiler here, go-sqlite3 requires cgo; full-module go build ./... OOMs locally; pnpm scoring:boundary hits the repo's own C:\C:\... Windows path bug while scoring/ is untouched by this PR.

@ghfind-review ghfind-review Bot added the review: low ghfind author score; see https://ghfind.com label Nov 4, 2026
@Yuncan050115
Yuncan050115 force-pushed the fix/hydrate-evidence-plain-403 branch from 2ff8f86 to 644e40a Compare November 4, 2026 16:38
@Yuncan050115 Yuncan050115 changed the title fix(backend): one README 403 aborted all remaining evidence collection (#621) fix(backend): continue evidence collection after a plain 403 (#621) Nov 4, 2026
@Yuncan050115
Yuncan050115 force-pushed the fix/hydrate-evidence-plain-403 branch from 644e40a to d69c03a Compare November 4, 2026 16:54
@Yuncan050115 Yuncan050115 changed the title fix(backend): continue evidence collection after a plain 403 (#621) fix(backend): a plain 403 must not abort the rest of evidence collection (#621) Nov 5, 2026
@Yuncan050115
Yuncan050115 force-pushed the fix/hydrate-evidence-plain-403 branch from a72d063 to bb1f315 Compare November 5, 2026 16:28
… abort

hydrateTopRepoEvidence compared readmeErr/languageErr with `!=` against
ErrGitHubUnavailable, but restGet wraps that sentinel with %w, so the
comparison never matched and one unreadable README aborted the whole
candidate loop. finishCollectedScan discards the returned error, so the
scan still reported complete_public while later repositories silently
lost their README, languages and root listing.

Use errors.Is, which is already this package's idiom for wrapped
sentinels. ErrGitHubRateLimited and the unwrapped 404 path are untouched,
so a drained token pool still aborts and a missing README still means
"no README".

Adds three httptest cases; the first one fails on the pre-fix code.

Fixes FindAny#621
FindAny#621 asks that a plain 403, a 403 carrying Retry-After, a rate-limit 403,
a 429 and a cancellation are not swallowed into one outcome. The errors.Is
change makes every wrapped ErrGitHubUnavailable skippable, so the visible
difference between "skip this repository" and "abort the scan" now depends
on how restGet classifies the response, not on this loop.

Adds a table over the real request path covering all five classes, with
request counts that also pin the retry budget (two attempts for a
single-token pool): a plain 403 is requested once and skipped, Retry-After
and rate-limit responses are retried before skipping or aborting, 429 and
context.Canceled abort, and an aborted scan never touches a later
repository.

Refs FindAny#621
@Yuncan050115
Yuncan050115 force-pushed the fix/hydrate-evidence-plain-403 branch from bb1f315 to 05b2edc Compare November 6, 2026 03:19
@AsperforMias

Copy link
Copy Markdown
Collaborator

Since 2026-11-07 ghfind is split into three repositories. This repository now holds only the public scoring module, SDKs, CLI and the deploy workflows; the code this PR touches moved to a private repository, so it can no longer be merged here.

The Go collector in internal/backend is no longer deployed: production scoring runs on Cloudflare Workers (TypeScript), and the Railway-era Go API binaries were removed. This fix therefore doesn't reach production. (Issue #621 describes the Go collector only.) Closing. Thank you for the careful analysis and tests!

仓库已于 2026-11-07 拆分为三个仓库,本 PR 涉及的代码已迁入私有仓库,无法在此合并。Go 采集器已不再部署(生产评分运行在 Cloudflare Workers 的 TypeScript 实现上),此修复不会影响线上,关闭。感谢细致的分析与测试!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: low ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants