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:
joshsiv-mulga
2026-07-13 22:08:14 +10:00
parent cee73671ff
commit daf637709c
3 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -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)
+2 -2
View File
@@ -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(`{
+1 -1
View File
@@ -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)