bugfix for model-mapper & model-router (#3370)

This commit is contained in:
rinfx
2026-01-28 10:52:45 +08:00
committed by GitHub
parent a92c89ce61
commit cbcc3ecf43
2 changed files with 13 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
package main
import (
"encoding/json"
"errors"
"sort"
"strings"
@@ -136,11 +137,8 @@ func onHttpRequestHeaders(ctx wrapper.HttpContext, config Config) types.Action {
break
}
}
if !matched {
return types.ActionContinue
}
if !ctx.HasRequestBody() {
if !matched || !ctx.HasRequestBody() {
ctx.DontReadRequestBody()
return types.ActionContinue
}
@@ -158,6 +156,11 @@ func onHttpRequestBody(ctx wrapper.HttpContext, config Config, body []byte) type
return types.ActionContinue
}
if !json.Valid(body) {
log.Error("invalid json body")
return types.ActionContinue
}
oldModel := gjson.GetBytes(body, config.modelKey).String()
newModel := config.defaultModel