fix(ci): fix gofmt, errcheck, and test for supported context-management beta token

This commit is contained in:
erio
2026-06-10 00:46:19 +08:00
parent 72c112164e
commit 448936d965
3 changed files with 10 additions and 9 deletions
+5 -5
View File
@@ -471,11 +471,11 @@ func parseAnthropicBetaHeader(header string) []string {
// 参考: AWS Bedrock 官方文档 + litellm anthropic_beta_headers_config.json
// 更新策略: 当 AWS Bedrock 新增支持的 beta token 时需同步更新此白名单
var bedrockSupportedBetaTokens = map[string]bool{
"computer-use-2025-01-24": true,
"computer-use-2025-11-24": true,
"context-1m-2025-08-07": true,
"context-management-2025-06-27": true, // compaction + clear_thinkingAWS 文档已支持
"compact-2026-01-12": true, // 官方支持,仅 InvokeModel APIOpus 4.6+
"computer-use-2025-01-24": true,
"computer-use-2025-11-24": true,
"context-1m-2025-08-07": true,
"context-management-2025-06-27": true, // compaction + clear_thinkingAWS 文档已支持
"compact-2026-01-12": true, // 官方支持,仅 InvokeModel APIOpus 4.6+
"fine-grained-tool-streaming-2025-05-14": true, // AWS Tool Use 文档已支持
// "interleaved-thinking-2025-05-14": false, // 无官方文档支持
"tool-search-tool-2025-10-19": true,
@@ -411,7 +411,7 @@ func TestPrepareBedrockRequestBodyWithTokens_ContextManagementRequiresSupportedB
assert.Equal(t, int64(100), gjson.GetBytes(result, "max_tokens").Int())
})
t.Run("filters explicit unsupported context-management beta and strips field", func(t *testing.T) {
t.Run("keeps supported context-management beta and retains field", func(t *testing.T) {
input := `{
"messages":[{"role":"user","content":"hi"}],
"max_tokens":100,
@@ -426,8 +426,8 @@ func TestPrepareBedrockRequestBodyWithTokens_ContextManagementRequiresSupportedB
)
require.NoError(t, err)
assert.False(t, gjson.GetBytes(result, "context_management").Exists())
assert.Equal(t, []string{"context-1m-2025-08-07"}, bedrockAnthropicBetaNames(result))
assert.True(t, gjson.GetBytes(result, "context_management").Exists())
assert.Equal(t, []string{bedrockContextManagementBetaToken, "context-1m-2025-08-07"}, bedrockAnthropicBetaNames(result))
})
}
@@ -298,7 +298,8 @@ func TestHandleErrorResponse_PassthroughRuleSetsCommitted(t *testing.T) {
assert.Equal(t, http.StatusBadRequest, rec.Code)
var payload map[string]any
require.NoError(t, json.Unmarshal(rec.Body.Bytes(), &payload))
errField := payload["error"].(map[string]any)
errField, ok := payload["error"].(map[string]any)
require.True(t, ok, "payload[\"error\"] should be map[string]any")
assert.Equal(t, "参数错误", errField["message"])
}