mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-15 17:11:30 +00:00
fix(bedrock): canonicalise HTTP header keys for canonicalheader lint
golangci-lint canonicalheader flagged 6 lowercase header literals in the Ochre/Bedrock gateway (anthropic.go, anthropic_test.go, vllm.go). Canonical form is wire-equivalent; canonicalise to X-Api-Key, Anthropic-Version and Content-Type to restore CI lint.
This commit is contained in:
@@ -135,9 +135,9 @@ func (p *anthropicProvider) Converse(ctx context.Context, modelID string, input
|
||||
slog.Error("anthropic: failed to build request", "model", modelID, "err", err)
|
||||
return nil, errors.New(awserrors.ErrorInternalError)
|
||||
}
|
||||
httpReq.Header.Set("x-api-key", apiKey)
|
||||
httpReq.Header.Set("anthropic-version", anthropicAPIVersion)
|
||||
httpReq.Header.Set("content-type", "application/json")
|
||||
httpReq.Header.Set("X-Api-Key", apiKey)
|
||||
httpReq.Header.Set("Anthropic-Version", anthropicAPIVersion)
|
||||
httpReq.Header.Set("Content-Type", "application/json")
|
||||
|
||||
start := time.Now()
|
||||
resp, err := p.httpClient.Do(httpReq)
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestAnthropicProvider_Converse_MapsResponse(t *testing.T) {
|
||||
var capturedAPIKey string
|
||||
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
capturedAPIKey = r.Header.Get("x-api-key")
|
||||
capturedAPIKey = r.Header.Get("X-Api-Key")
|
||||
require.NoError(t, json.NewDecoder(r.Body).Decode(&capturedBody))
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
@@ -96,7 +96,7 @@ func TestAnthropicProvider_Converse_401ReturnsAccessDenied(t *testing.T) {
|
||||
// redirect it at an httptest stub instead of the network.
|
||||
func TestAnthropicBoundProvider_Converse(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, "sk-bound-test", r.Header.Get("x-api-key"))
|
||||
assert.Equal(t, "sk-bound-test", r.Header.Get("X-Api-Key"))
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = w.Write([]byte(`{
|
||||
|
||||
@@ -125,7 +125,7 @@ func (p *vllmProvider) Converse(ctx context.Context, modelID string, input *bedr
|
||||
slog.Error("vllm: failed to build request", "model", modelID, "err", err)
|
||||
return nil, errors.New(awserrors.ErrorInternalError)
|
||||
}
|
||||
httpReq.Header.Set("content-type", "application/json")
|
||||
httpReq.Header.Set("Content-Type", "application/json")
|
||||
|
||||
start := time.Now()
|
||||
resp, err := p.httpClient.Do(httpReq)
|
||||
|
||||
Reference in New Issue
Block a user