Files
vscode/extensions
Bhavya U 49d32125de External ingest: harden finalize against 412 phase mismatch (#322254)
* External ingest: harden finalize against 412 phase mismatch

Fixes the "Build Codebase Semantic Index" failure for non-GitHub repos
where `/external/code/ingest/finalize` returns HTTP 412 ("request sent
for phase which was not the current phase"). The server only advances to
the finalize phase once it has received every expected document, so a
finalize can fail when the server is still missing documents.

- Retry finalize with backoff (bounded) after a 412, re-polling `/batch`
  for documents the server still reports as missing and re-uploading them.
- Stop swallowing per-document upload failures: collect them and fail the
  pass with a descriptive error (status + requestId) before finalize, so
  the real cause is surfaced instead of a misleading finalize 412. Failed
  uploads are no longer counted as uploaded.
- Make a `/document` 404 ("ingest is gone") abort the pass deterministically
  rather than relying on a rejection an intermediate `Promise.all` can swallow.
- When finalize keeps returning 412 but the server reports no missing
  documents, surface a distinct "likely server-side" error after retries.

Adds an ExternalIngestClient test suite driving the real client through the
ingest HTTP protocol (retry-then-success, re-upload still-missing, exhaustion,
server-side-no-missing-docs, persistent upload failure, and 404 abort).

Refs microsoft/vscode#320915

* Use fake timers for finalize-retry tests; count unique uploaded docShas

- Test suite uses fake timers so finalize-retry backoff doesn't add real wall-clock time
- Record unmapped docSha as a deterministic upload failure instead of throwing (rejection was swallowed by Promise.all)
- updatedFileCount counts unique uploaded docShas across passes instead of summing per-pass attempts
- Add test for the unmapped-docSha failure path

* Fix externalIngest tests failing in CI without a GitHub token

createPlatformServices() wires a static auth service backed by createStaticGitHubTokenProvider(), which throws when no GITHUB_PAT/GITHUB_OAUTH_TOKEN is set (CI). Override IAuthenticationService with a static token so getAuthToken() resolves deterministically. Verified by running the suite with the token env vars unset.
2026-06-22 10:48:33 -07:00
..