flipped-aurora/gin-vue-admin · error

需求分析失败: %v

Error message

需求分析失败: %v

What it means

Wrap of any failure inside requirement_analyzer's analyzeRequirement, including the LLM/API call it performs. It signals that the natural-language requirement analysis step failed, before any JSON serialization happens.

Source

Thrown at server/mcp/requirement_analyzer.go:72

 `),
		mcp.WithString("userRequirement",
			mcp.Required(),
			mcp.Description("用户的需求描述,支持自然语言,如:'我要做一个猫舍管理系统,用来录入猫的信息,并且记录每只猫每天的活动信息'"),
		),
	)
}

// Handle 处理工具调用
func (t *RequirementAnalyzer) Handle(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
	userRequirement, ok := request.GetArguments()["userRequirement"].(string)
	if !ok || userRequirement == "" {
		return nil, errors.New("参数错误:userRequirement 必须是非空字符串")
	}

	// 分析用户需求
	analysisResponse, err := t.analyzeRequirement(userRequirement)
	if err != nil {
		return nil, fmt.Errorf("需求分析失败: %v", err)
	}

	// 序列化响应
	return textResultWithJSON("", analysisResponse)
}

// analyzeRequirement 分析用户需求 - 专注于AI需求传递
func (t *RequirementAnalyzer) analyzeRequirement(userRequirement string) (*RequirementAnalysisResponse, error) {
	// 生成AI提示词 - 这是唯一功能
	aiPrompt := t.generateAIPrompt(userRequirement)

	return &RequirementAnalysisResponse{
		AIPrompt: aiPrompt,
	}, nil
}

// generateAIPrompt 生成AI提示词 - 智能分析需求并确定模块结构
func (t *RequirementAnalyzer) generateAIPrompt(userRequirement string) string {

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Read the wrapped %v cause to identify whether it is auth, network, or quota
  2. Check the analysis backend API key/endpoint configuration on the MCP server
  3. Retry with a shorter userRequirement if a context/length error is reported
  4. Handle provider rate limits with backoff before retrying
Defensive patterns

Strategy: try-catch

Validate before calling

if strings.TrimSpace(userRequirement) == "" {
    return errors.New("userRequirement must be a non-empty string")
}
if len(userRequirement) > maxPromptLen {
    return fmt.Errorf("userRequirement too long: %d > %d", len(userRequirement), maxPromptLen)
}

Try / catch

analysis, err := analyzer.Handle(ctx, args)
if err != nil {
    var rateLimit *RateLimitError
    switch {
    case errors.As(err, &rateLimit):
        time.Sleep(rateLimit.RetryAfter); return retry(args)
    case isAuthError(err):
        return fmt.Errorf("check LLM API key config: %w", err)
    default:
        return err
    }
}

Prevention

When it happens

Trigger: Handle receives a valid non-empty userRequirement, but analyzeRequirement errors — typically the downstream analysis backend (LLM endpoint) is unreachable, returns an error, rate-limits, or times out.

Common situations: Missing or invalid LLM API key in MCP server config; network egress blocked; provider rate limit/quota exhausted; prompt too long exceeding model context limit.

Related errors


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