Explorar o código

fix: user ast node not exsit (#189)

zijiren hai 7 meses
pai
achega
7535c80af6
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      core/middleware/distributor.go

+ 3 - 0
core/middleware/distributor.go

@@ -516,6 +516,9 @@ func getRequestUser(c *gin.Context, m mode.Mode) (string, error) {
 func GetRequestUserFromJSON(body []byte) (string, error) {
 	node, err := sonic.GetWithOptions(body, ast.SearchOptions{}, "user")
 	if err != nil {
+		if errors.Is(err, ast.ErrNotExist) {
+			return "", nil
+		}
 		return "", fmt.Errorf("get request user failed: %w", err)
 	}
 	if node.Exists() {