This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Fix annoying consistency#63623
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.goexposes this function:https://github.com/sourcegraph/sourcegraph/blob/da5968ba1ef1be0307a88b78ccb621a4ff1bef9f/internal/completions/client/azureopenai/openai.go#L116
Note the order of the parameters:
accessTokenand thenendpoint.This is where it is called. Notice the order of parameters
endpointand thenaccessToken.https://github.com/sourcegraph/sourcegraph/blob/da5968ba1ef1be0307a88b78ccb621a4ff1bef9f/internal/completions/client/client.go#L40-L41
But there is another layer of indirection, the
type GetCompletionsAPIClientFunc func(accessToken, endpoint string) (CompletionsClient, error). But this too has the parameters asaccessTokenand thenendpoint.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
endpointand thenaccessToken.... and that's why things are totally working just fine. The reality is that the first parameter should-be-and-is
endpointand the second parameter should-be-and-isaccessToken. But withinfunc NewClientandtype GetCompletionsAPIClientFuncthese are mislabeled.Test plan
NA
Changelog
NA