flipped-aurora/gin-vue-admin · error

参数错误:generatedFiles 不能为空

Error message

参数错误:generatedFiles 不能为空

What it means

After successfully unmarshalling 'generatedFiles' into a []string, Handle rejects an empty array with this error. The reviewer needs at least one file path to build the adjustment prompt; an empty list would produce a meaningless review, so it is treated as invalid input.

Source

Thrown at server/mcp/gva_review.go:92

	generatedFilesData, ok := request.GetArguments()["generatedFiles"]
	if !ok {
		return nil, errors.New("参数错误:generatedFiles 必须提供")
	}

	generatedFilesStr, ok := generatedFilesData.(string)
	if !ok {
		return nil, errors.New("参数错误:generatedFiles 必须是JSON字符串")
	}

	// 解析JSON字符串为字符串数组
	var generatedFiles []string
	err := json.Unmarshal([]byte(generatedFilesStr), &generatedFiles)
	if err != nil {
		return nil, fmt.Errorf("解析generatedFiles失败: %v", err)
	}

	if len(generatedFiles) == 0 {
		return nil, errors.New("参数错误:generatedFiles 不能为空")
	}

	// 直接生成调整提示,不进行复杂分析
	adjustmentPrompt := g.generateAdjustmentPrompt(userRequirement, generatedFiles)

	// 构建简化的审查详情
	reviewDetails := fmt.Sprintf("📋 **代码审查报告**\n\n **用户原始需求:**\n%s\n\n **已生成文件数量:** %d\n\n **建议进行代码优化和完善**", userRequirement, len(generatedFiles))

	// 构建审查结果
	reviewResult := &ReviewResponse{
		Success:          true,
		Message:          "代码审查完成",
		AdjustmentPrompt: adjustmentPrompt,
		ReviewDetails:    reviewDetails,
	}

	// 序列化响应
	return textResultWithJSON("代码审查结果:", reviewResult)

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Populate the array with at least one valid file path before calling the tool.
  2. Fix the upstream file-collection logic so it actually gathers generated files (log the list before sending).
  3. If nothing was generated, skip the review call instead of invoking it with an empty list.
  4. Validate on the client: marshal the list, check len > 0, then call.

Example fix

// before
if err := json.Unmarshal(b, &files); err != nil { return err }
callReview(req, files) // files may be empty
// after
if err := json.Unmarshal(b, &files); err != nil { return err }
if len(files) == 0 { return errors.New("no generated files to review") }
callReview(req, files)
Defensive patterns

Strategy: validation

Validate before calling

var files []string
_ = json.Unmarshal([]byte(generatedFilesStr), &files)
if len(files) == 0 {
    return errors.New("refusing to call gva_review with an empty generatedFiles list")
}

Prevention

When it happens

Trigger: Calling gva_review with 'generatedFiles' set to "[]" or a JSON string that unmarshals to a zero-length slice.

Common situations: File-collection step upstream produced no results (glob matched nothing, all files filtered out); caller passes a placeholder empty array to satisfy the presence check from error 32; logic bug where files were added to the wrong variable.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/ff6539e22766c6b2. Report an issue: GitHub.