feat: publish v1.0.0-rc.36-custom.1
This commit is contained in:
commit
3a7e8f3b54
2381 files changed
+551494
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/QuantumNous/new-api/relaykit/types"
|
||||
)
|
||||
|
||||
func TestClientFacingOpenAIErrorHidesUpstreamDetails(t *testing.T) {
|
||||
err := types.NewOpenAIError(errors.New("provider.example.invalid provider secret failure"), types.ErrorCodeBadResponseStatusCode, http.StatusBadGateway)
|
||||
got := clientFacingOpenAIError(err, true, "local-request-id")
|
||||
|
||||
if strings.Contains(got.Message, "example-provider") || strings.Contains(got.Message, "provider secret") {
|
||||
t.Fatalf("upstream details leaked: %q", got.Message)
|
||||
}
|
||||
if !strings.Contains(got.Message, "local-request-id") {
|
||||
t.Fatalf("local request id missing: %q", got.Message)
|
||||
}
|
||||
if got.Code != "model_service_error" {
|
||||
t.Fatalf("unexpected public code: %v", got.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientFacingClaudeErrorHidesUpstreamDetails(t *testing.T) {
|
||||
err := types.NewOpenAIError(errors.New("provider.example.invalid provider secret failure"), types.ErrorCodeBadResponseStatusCode, http.StatusBadGateway)
|
||||
got := clientFacingClaudeError(err, true, "local-request-id")
|
||||
|
||||
if strings.Contains(got.Message, "example-provider") || strings.Contains(got.Message, "provider secret") {
|
||||
t.Fatalf("upstream details leaked: %q", got.Message)
|
||||
}
|
||||
if !strings.Contains(got.Message, "local-request-id") {
|
||||
t.Fatalf("local request id missing: %q", got.Message)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientFacingErrorKeepsLocalValidationMessage(t *testing.T) {
|
||||
err := types.NewErrorWithStatusCode(errors.New("model is required"), types.ErrorCodeInvalidRequest, http.StatusBadRequest)
|
||||
got := clientFacingOpenAIError(err, false, "local-request-id")
|
||||
if !strings.Contains(got.Message, "model is required") {
|
||||
t.Fatalf("local validation message was hidden: %q", got.Message)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user