From 23b962a90e3c36265939d7833e63254d7d542801 Mon Sep 17 00:00:00 2001 From: sun <3371392206@qq.com> Date: Tue, 26 May 2026 10:41:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E4=BD=93=E8=BF=87=E5=A4=A7=E5=A4=84=E7=90=86=E5=92=8C=E5=86=97?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 修复OpenAI TTS接口的请求体过大错误提示,返回正确的状态码和提示信息 2. 删除volcano适配器中无用的空循环扫描代码 3. 修正constants.go的包声明重复空格问题 --- adapter/volcano/volcano.go | 2 -- common/constants.go | 2 +- controller/tts.go | 9 +++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/adapter/volcano/volcano.go b/adapter/volcano/volcano.go index 603ff7c..3453b76 100644 --- a/adapter/volcano/volcano.go +++ b/adapter/volcano/volcano.go @@ -132,8 +132,6 @@ func Synthesis(config *dto.ByteDanceTTSConfig, httpClient *HTTPClient, text stri if v3Resp.Usage != nil { log.Printf("TTS synthesis completed, usage: %+v", v3Resp.Usage) } - for scanner.Scan() { - } break } diff --git a/common/constants.go b/common/constants.go index ea7a6d9..853ca08 100644 --- a/common/constants.go +++ b/common/constants.go @@ -1,4 +1,4 @@ -package common +package common import "time" diff --git a/controller/tts.go b/controller/tts.go index 03c6297..7a40da9 100644 --- a/controller/tts.go +++ b/controller/tts.go @@ -58,10 +58,11 @@ func OpenaiTTSHandler(w http.ResponseWriter, r *http.Request) { r.Body = http.MaxBytesReader(w, r.Body, common.MaxRequestBodySize) body, err := io.ReadAll(r.Body) if err != nil { - if strings.Contains(err.Error(), "request body too large") { - return - } - http.Error(w, "Failed to read request body", http.StatusBadRequest) + if strings.Contains(err.Error(), "request body too large") { + http.Error(w, fmt.Sprintf("Request body too large (max %d bytes)", common.MaxRequestBodySize), http.StatusRequestEntityTooLarge) + return + } + http.Error(w, "Failed to read request body", http.StatusBadRequest) return }