diff --git a/cmd/frontend/internal/context/resolvers/context_test.go b/cmd/frontend/internal/context/resolvers/context_test.go index a7993575e99..78c24516892 100644 --- a/cmd/frontend/internal/context/resolvers/context_test.go +++ b/cmd/frontend/internal/context/resolvers/context_test.go @@ -33,10 +33,20 @@ import ( func TestContextResolver(t *testing.T) { logger := logtest.Scoped(t) ctx := context.Background() - db := database.NewDB(logger, dbtest.NewDB(t)) repo1 := types.Repo{Name: "repo1"} repo2 := types.Repo{Name: "repo2"} + truePtr := true + conf.Mock(&conf.Unified{ + SiteConfiguration: schema.SiteConfiguration{ + CodyEnabled: &truePtr, + Embeddings: &schema.Embeddings{ + Provider: "sourcegraph", + Enabled: &truePtr, + AccessToken: "123", + }, + }, + }) // Create populates the IDs in the passed in types.Repo err := db.Repos().Create(ctx, &repo1, &repo2) require.NoError(t, err) @@ -139,13 +149,6 @@ func TestContextResolver(t *testing.T) { contextClient, ) - truePtr := true - conf.Mock(&conf.Unified{ - SiteConfiguration: schema.SiteConfiguration{ - CodyEnabled: &truePtr, - }, - }) - ctx = actor.WithActor(ctx, actor.FromMockUser(1)) ffs := featureflag.NewMemoryStore(map[string]bool{"cody": true}, nil, nil) ctx = featureflag.WithFlags(ctx, ffs) diff --git a/internal/codycontext/context.go b/internal/codycontext/context.go index e47c8e532b8..39f2acefd86 100644 --- a/internal/codycontext/context.go +++ b/internal/codycontext/context.go @@ -160,6 +160,10 @@ func (c *CodyContextClient) GetCodyContext(ctx context.Context, args GetContextA // partitionRepos splits a set of repos into repos with embeddings and repos without embeddings func (c *CodyContextClient) partitionRepos(ctx context.Context, input []types.RepoIDName) (embedded, notEmbedded []types.RepoIDName, err error) { + // if embeddings are disabled , return all repos in the notEmbedded slice + if !conf.EmbeddingsEnabled() { + return nil, input, nil + } for _, repo := range input { exists, err := c.db.Repos().RepoEmbeddingExists(ctx, repo.ID) if err != nil {