Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

gitserver: RawDiff checks if commits exist#64245

Merged
keegancsmith merged 1 commit into
mainfrom
k/resolve-revision
Aug 2, 2024
Merged

gitserver: RawDiff checks if commits exist#64245
keegancsmith merged 1 commit into
mainfrom
k/resolve-revision

Conversation

@keegancsmith

Copy link
Copy Markdown
Member

ResolveRevision additionally adds a "^0" to the spec to make sure we actually check if it exists. This is important, since most uses of the ChangedFiles API pass in commit shas which do not get resolved by git unless the "^0" is present.

I noticed this since hybrid search in searcher started to fail if the commit was missing. In particular Zoekt for empty repositories uses a fake SHA of 404aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa so when a repo started getting cloned hybrid search would fail until it was indexed. Hybrid search explicitly checks for the NotFound error, so hybrid search failing was a a regression from moving away from the SymbolDiff API.

Fixes https://linear.app/sourcegraph/issue/SPLF-166/hybrid-search-handles-missing-indexed-commit

image

Test plan

added a test case which failed before this commit.

Changelog

Fixes a bug where a force push on HEAD of a repository might lead to our unindexed search failing until the indexed search had updated.

ResolveRevision additionally adds a "^0" to the spec to make sure we
actually check if it exists. This is important, since most uses of the
ChangedFiles API pass in commit shas which do not get resolved by git
unless the "^0" is present.

I noticed this since hybrid search in searcher started to fail if the
commit was missing. In particular Zoekt for empty repositories uses a
fake SHA of 404aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa so when a repo
started getting cloned hybrid search would fail until it was indexed.
Hybrid search explicitly checks for the NotFound error, so hybrid search
failing was a a regression from moving away from the SymbolDiff API.

Test Plan: added a test case which failed before this commit.
@keegancsmith keegancsmith requested review from a team and eseliger August 2, 2024 13:00
@cla-bot cla-bot Bot added the cla-signed label Aug 2, 2024
@github-actions github-actions Bot added team/product-platform team/search-platform Issues owned by the search platform team labels Aug 2, 2024

@eseliger eseliger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, also for tests!

require.Error(t, err)
require.True(t, errors.HasType[*gitdomain.RevisionNotFoundError](err))
// Test with both an unknown ref that needs resolving and something
// that looks like a sha256 (hits different code paths inside of git)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh man this has been a footgun so many times already

@keegancsmith keegancsmith enabled auto-merge (squash) August 2, 2024 13:03
@keegancsmith keegancsmith merged commit f7d62a3 into main Aug 2, 2024
@keegancsmith keegancsmith deleted the k/resolve-revision branch August 2, 2024 13:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed team/product-platform team/search-platform Issues owned by the search platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants