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

Commit 98ba21d

Browse files
authored
[Backport 5.1]: Allow for null revision resolver when using repo embeddings job's empty revision string (#54881)
This [PR](https://github.com/sourcegraph/sourcegraph/pull/54804) fixed an issue with job scheduling/execution in the backend. The interim fix of this PR relies on allowing for empty string `revision` values written with a repo embedding job when the repo is empty or some other issue occurs when fetching the repo's default branch (e.g. empty repo). Empty revision value causes issues with graphql query repoEmbeddingJobs when [querying for Revision](https://sourcegraph.com/github.com/sourcegraph/sourcegraph/-/blob/client/web/src/enterprise/site-admin/cody/backend.ts?L32-35) as our site admin jobs panel does. `Panic occurred: runtime error: slice bounds out of range [:7] with length 0` This PR updates the embedding job resolver to consider empty revision string acceptable and not call constructor for git commit resolver. Also site admin jobs list will now show repo name if repo is non-null and revision is null. Backport of https://github.com/sourcegraph/sourcegraph/pull/54879
1 parent 55ca3f7 commit 98ba21d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

client/web/src/enterprise/site-admin/cody/RepoEmbeddingJobNode.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export const RepoEmbeddingJobNode: FC<RepoEmbeddingJobNodeProps> = ({
5050
<Link to={`${repo.url}@${revision.oid}`}>
5151
{repo.name}@{revision.abbreviatedOID}
5252
</Link>
53+
) : repo ? (
54+
<>{repo.name}</>
5355
) : (
5456
<div>Unknown repository</div>
5557
)}

enterprise/cmd/frontend/internal/embeddings/resolvers/repo_embedding_jobs.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,16 @@ func (r *repoEmbeddingJobResolver) Revision(ctx context.Context) (*graphqlbacken
214214
if err != nil {
215215
return nil, err
216216
}
217-
if repoResolver == nil {
217+
218+
// An empty revision value can accompany a valid repository if gitserver cannot resolve the default branch or latest revision during job scheduling.
219+
// The job will always fail in this case and must be displayed in site admin despite the gitserver error.
220+
// Site admin will only provide the job's failure_message in this case.
221+
invalidRevision := r.job.Revision == ""
222+
223+
if repoResolver == nil || invalidRevision {
218224
return nil, nil
219225
}
226+
220227
return graphqlbackend.NewGitCommitResolver(r.db, r.gitserverClient, repoResolver, r.job.Revision, nil), nil
221228
}
222229

0 commit comments

Comments
 (0)