From daf637709cb2ff2802d60c9d14c864eb957d35b0 Mon Sep 17 00:00:00 2001 From: joshsiv-mulga Date: Mon, 13 Jul 2026 22:08:14 +1000 Subject: [PATCH] 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. --- spinifex/gateway/bedrock/anthropic.go | 6 +++--- spinifex/gateway/bedrock/anthropic_test.go | 4 ++-- spinifex/gateway/bedrock/vllm.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spinifex/gateway/bedrock/anthropic.go b/spinifex/gateway/bedrock/anthropic.go index 9b9ad292f..f246dee97 100644 --- a/spinifex/gateway/bedrock/anthropic.go +++ b/spinifex/gateway/bedrock/anthropic.go @@ -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) diff --git a/spinifex/gateway/bedrock/anthropic_test.go b/spinifex/gateway/bedrock/anthropic_test.go index 06901e199..2dd3df4bb 100644 --- a/spinifex/gateway/bedrock/anthropic_test.go +++ b/spinifex/gateway/bedrock/anthropic_test.go @@ -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(`{ diff --git a/spinifex/gateway/bedrock/vllm.go b/spinifex/gateway/bedrock/vllm.go index 4b76bd8cf..853e706f2 100644 --- a/spinifex/gateway/bedrock/vllm.go +++ b/spinifex/gateway/bedrock/vllm.go @@ -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)