mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-13 23:11:40 +00:00
fix(terraform): reject empty-body 2xx responses in mcp server handler
This commit is contained in:
parent
9d02b4546f
commit
825b092015
2 changed files with 3 additions and 7 deletions
|
|
@ -147,10 +147,6 @@ func handleMCPAPIResponse(resp *http.Response, result interface{}, client *Clien
|
|||
resp.Status, client.redactSensitiveData(string(bodyBytes)))
|
||||
}
|
||||
|
||||
if len(bodyBytes) == 0 || string(bodyBytes) == "null" {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(bodyBytes, result); err != nil {
|
||||
return fmt.Errorf("failed to parse response: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func TestHandleMCPAPIResponseAcceptsFullSuccessRange(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandleMCPAPIResponseAcceptsEmptyBodyOn2xx(t *testing.T) {
|
||||
func TestHandleMCPAPIResponseRejectsEmptyBodyOn2xx(t *testing.T) {
|
||||
rec := httptest.NewRecorder()
|
||||
rec.WriteHeader(http.StatusNoContent)
|
||||
resp := rec.Result()
|
||||
|
|
@ -122,7 +122,7 @@ func TestHandleMCPAPIResponseAcceptsEmptyBodyOn2xx(t *testing.T) {
|
|||
var mcpResp MCPServerResponse
|
||||
err := handleMCPAPIResponse(resp, &mcpResp, client)
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("handleMCPAPIResponse returned unexpected error for empty-body 204: %v", err)
|
||||
if err == nil {
|
||||
t.Fatal("handleMCPAPIResponse returned no error for empty-body 204; every MCP caller (create/read/update) writes the parsed result straight into Terraform state with no fallback, so a silently-accepted empty body would blank out or empty-ID the resource")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue