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

Fix annoying consistency#63623

Merged
chrsmith merged 1 commit into
mainfrom
chrsmith/fix-annoying-inconsistency
Jul 3, 2024
Merged

Fix annoying consistency#63623
chrsmith merged 1 commit into
mainfrom
chrsmith/fix-annoying-inconsistency

Conversation

@chrsmith

@chrsmith chrsmith commented Jul 3, 2024

Copy link
Copy Markdown
Contributor

Fix an annoying inconsistency. There isn't a functional change here, but it's confusing and error prone enough that we need to make this fix.

internal/completions/client/azureopenai/openai.go exposes this function:

https://github.com/sourcegraph/sourcegraph/blob/da5968ba1ef1be0307a88b78ccb621a4ff1bef9f/internal/completions/client/azureopenai/openai.go#L116

Note the order of the parameters: accessToken and then endpoint.

This is where it is called. Notice the order of parameters endpoint and then accessToken.

https://github.com/sourcegraph/sourcegraph/blob/da5968ba1ef1be0307a88b78ccb621a4ff1bef9f/internal/completions/client/client.go#L40-L41

⚠️ So this is a bug, right?!? Due to some copy and paste error we're passing an access token to the parameter slot that should be an endpoint.

But there is another layer of indirection, the type GetCompletionsAPIClientFunc func(accessToken, endpoint string) (CompletionsClient, error). But this too has the parameters as accessToken and then endpoint.

But if you go to the actual implementation of that function azureopenai.GetAPIClient, defined here:
https://github.com/sourcegraph/sourcegraph/blob/da5968ba1ef1be0307a88b78ccb621a4ff1bef9f/internal/completions/client/azureopenai/openai.go#L57

You see that the first parameter is actually endpoint and then accessToken.

... and that's why things are totally working just fine. The reality is that the first parameter should-be-and-is endpoint and the second parameter should-be-and-is accessToken. But within func NewClient and type GetCompletionsAPIClientFunc these are mislabeled.

Test plan

NA

Changelog

NA

@chrsmith chrsmith requested a review from emidoots July 3, 2024 20:25
@cla-bot cla-bot Bot added the cla-signed label Jul 3, 2024

@emidoots emidoots 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.

....

@chrsmith chrsmith merged commit b9e118d into main Jul 3, 2024
@chrsmith chrsmith deleted the chrsmith/fix-annoying-inconsistency branch July 3, 2024 21:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants