Cody: add support for neovim, cody-cli, eclipse, and visualstudio clients (#63851)

Fixes CODY-2884

Previously, the server could respond with a 406 error when encountering
clients with the following names: cody-cli, eclipse, and visualstudio.
This error seems to only happen for enterprise clients. This PR fixes
the problem by adding special cases for these clients like we already
have for jetbrains and cody web.

<!-- PR description tips:
https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e
-->

## Test plan

See updated test case.
<!-- REQUIRED; info at
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles
-->

## Changelog

- Fix HTTP 406 error when using the Neovim Cody plugin with Enterprise
instances
<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
This commit is contained in:
Ólafur Páll Geirsson 2024-07-16 14:36:44 +02:00 committed by Olafur Geirsson
parent 20adc60d67
commit 7bc210bd4e
3 changed files with 29 additions and 5 deletions

View File

@ -555,6 +555,10 @@ func checkClientCodyIgnoreCompatibility(ctx context.Context, db database.DB, r *
}
var cvc clientVersionConstraint
switch clientName {
case types.CodyClientEclipse:
case types.CodyClientVisualStudio:
case types.CodyClientNeovim:
case types.CodyClientCli:
case types.CodyClientWeb:
// Cody Web is of the same version as the Sourcegraph instance, thus no version constraint is needed.
return nil
@ -572,7 +576,15 @@ func checkClientCodyIgnoreCompatibility(ctx context.Context, db database.DB, r *
}
default:
return &codyIgnoreCompatibilityError{
reason: fmt.Sprintf("please use one of the supported clients: %s, %s, %s.", types.CodyClientVscode, types.CodyClientJetbrains, types.CodyClientWeb),
reason: fmt.Sprintf("please use one of the supported clients: %s, %s, %s, %s, %s, %s, %s.",
types.CodyClientVscode,
types.CodyClientJetbrains,
types.CodyClientWeb,
types.CodyClientEclipse,
types.CodyClientCli,
types.CodyClientVisualStudio,
types.CodyClientNeovim,
),
statusCode: http.StatusNotAcceptable,
}
}

View File

@ -84,7 +84,15 @@ func TestCheckClientCodyIgnoreCompatibility(t *testing.T) {
"client-name": []string{"sublime"},
},
want: &codyIgnoreCompatibilityError{
reason: fmt.Sprintf("please use one of the supported clients: %s, %s, %s.", types.CodyClientVscode, types.CodyClientJetbrains, types.CodyClientWeb),
reason: fmt.Sprintf("please use one of the supported clients: %s, %s, %s, %s, %s, %s, %s.",
types.CodyClientVscode,
types.CodyClientJetbrains,
types.CodyClientWeb,
types.CodyClientEclipse,
types.CodyClientCli,
types.CodyClientVisualStudio,
types.CodyClientNeovim,
),
statusCode: http.StatusNotAcceptable,
},
},

View File

@ -227,9 +227,13 @@ const (
type CodyClientName string
const (
CodyClientWeb CodyClientName = "web"
CodyClientVscode CodyClientName = "vscode"
CodyClientJetbrains CodyClientName = "jetbrains"
CodyClientWeb CodyClientName = "web"
CodyClientVscode CodyClientName = "vscode"
CodyClientJetbrains CodyClientName = "jetbrains"
CodyClientEclipse CodyClientName = "eclipse"
CodyClientVisualStudio CodyClientName = "visualstudio"
CodyClientNeovim CodyClientName = "neovim"
CodyClientCli CodyClientName = "cody-cli"
)
type CompletionRequest struct {