flipped-aurora/gin-vue-admin · error
没有要创建的API
Error message
没有要创建的API
What it means
Thrown by ApiCreator's Handle after argument parsing when neither the bulk "apis" array nor the single-API fields produced any API entries, i.e. len(apis) == 0. This guards against a no-op tool call that would otherwise return an empty success response.
Source
Thrown at server/mcp/api_creator.go:100
if !ok || apiGroup == "" {
return nil, errors.New("apiGroup 参数是必需的")
}
method := "POST"
if value, ok := args["method"].(string); ok && value != "" {
method = value
}
apis = append(apis, ApiCreateRequest{
Path: path,
Description: description,
ApiGroup: apiGroup,
Method: method,
})
}
if len(apis) == 0 {
return nil, errors.New("没有要创建的API")
}
responses := make([]ApiCreateResponse, 0, len(apis))
successCount := 0
for _, apiReq := range apis {
// 批量模式给缺省 method 兜底 POST,与单条模式及 schema 默认值一致;
// 否则空 method 会被上游 ApiVerify 判"Method 不能为空"导致该条静默失败
if apiReq.Method == "" {
apiReq.Method = "POST"
}
// createApi 现回传创建后的实体(含自增 ID),直接取用,免去此前逐条回查 getApiList 的 2N 次调用
createResp, err := postUpstream[system.SysApi](ctx, "/api/createApi", system.SysApi{
Path: apiReq.Path,
Description: apiReq.Description,
ApiGroup: apiReq.ApiGroup,
Method: apiReq.Method,
})View on GitHub (pinned to 3136500ef3)
Solutions
- Populate the "apis" JSON array with at least one API object (path, description, apiGroup, optional method).
- If only one API is needed, provide the individual path/description/apiGroup arguments instead.
- Fix upstream serialization so an empty list is not sent; skip the tool call entirely when there is nothing to create.
Example fix
// before
{"arguments": {"apis": "[]"}}
// after
{"arguments": {"apis": "[{\"path\":\"/user/list\",\"description\":\"获取用户列表\",\"apiGroup\":\"user\",\"method\":\"POST\"}]"}} Defensive patterns
Strategy: validation
Validate before calling
let apis = JSON.parse(args.apis || "[]")
if (!Array.isArray(apis) || apis.length === 0) {
throw new Error("api_creator called with no APIs to create; skipping")
} Type guard
function hasApis(args) {
if (typeof args.apis !== "string") return false
try {
const parsed = JSON.parse(args.apis)
return Array.isArray(parsed) && parsed.length > 0
} catch {
return false
}
} Try / catch
try {
await callTool("api_creator", { apis })
} catch (e) {
if (e.message.includes("没有要创建的API")) {
// nothing to create — return early instead of retrying
}
} Prevention
- Check apis.length > 0 before invoking the tool.
- Skip the tool call entirely when the batch is empty.
- Ensure serializers do not emit "[]" placeholders for empty batches.
When it happens
Trigger: Calling api_creator with an "apis" argument that parses to an empty JSON array ("[]"), or with no valid API-defining arguments at all.
Common situations: Agents sending "apis": "[]" placeholders; upstream code serializing an empty slice to the apis argument; callers passing neither apis nor the individual path/description/apiGroup fields.
Related errors
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/0f899c96a3ed8616.
Report an issue: GitHub.