flipped-aurora/gin-vue-admin · error
模块 %d 的 structName 不能为空
Error message
模块 %d 的 structName 不能为空
What it means
validateExecutionPlan (server/mcp/gva_execute.go:329) rejects an ExecutionPlan when a module in modulesInfo has an empty structName. structName is the Go struct name for the generated model (upper camel case, e.g. UserInfo); the code generator cannot name the module's structs, files and tables without it. The module index in the message is 1-based.
Source
Thrown at server/mcp/gva_execute.go:329
if plan.PackageInfo.Label == "" {
return errors.New("packageInfo.label 不能为空")
}
if plan.PackageInfo.Desc == "" {
return errors.New("packageInfo.desc 不能为空")
}
}
if plan.NeedCreatedModules {
if len(plan.ModulesInfo) == 0 {
return errors.New("当 needCreatedModules=true 时,modulesInfo 不能为空")
}
for moduleIndex, moduleInfo := range plan.ModulesInfo {
if moduleInfo.Package == "" {
return fmt.Errorf("模块 %d 的 package 不能为空", moduleIndex+1)
}
if moduleInfo.StructName == "" {
return fmt.Errorf("模块 %d 的 structName 不能为空", moduleIndex+1)
}
if moduleInfo.TableName == "" {
return fmt.Errorf("模块 %d 的 tableName 不能为空", moduleIndex+1)
}
if moduleInfo.Description == "" {
return fmt.Errorf("模块 %d 的 description 不能为空", moduleIndex+1)
}
if moduleInfo.Abbreviation == "" {
return fmt.Errorf("模块 %d 的 abbreviation 不能为空", moduleIndex+1)
}
if moduleInfo.PackageName == "" {
return fmt.Errorf("模块 %d 的 packageName 不能为空", moduleIndex+1)
}
if moduleInfo.HumpPackageName == "" {
return fmt.Errorf("模块 %d 的 humpPackageName 不能为空", moduleIndex+1)
}
if len(moduleInfo.Fields) == 0 {
return fmt.Errorf("模块 %d 的 fields 不能为空,至少需要一个字段", moduleIndex+1)View on GitHub (pinned to 3136500ef3)
Solutions
- Locate the module at the reported 1-based index in modulesInfo.
- Set "structName" to an upper-camel-case Go name, e.g. "UserInfo".
- Derive related fields consistently: humpPackageName from the struct's lower-camel form, tableName in snake_case.
- Verify remaining required fields (package, tableName, description, abbreviation, packageName, humpPackageName, fields) are all present to avoid further validation rounds.
Example fix
// before
"modulesInfo":[{"package":"user","tableName":"users","description":"用户管理", ...}]
// after
"modulesInfo":[{"package":"user","structName":"User","tableName":"users","description":"用户管理", ...}] Defensive patterns
Strategy: validation
Validate before calling
function validateStructNames(modulesInfo) {
modulesInfo?.forEach((m, i) => {
if (typeof m.structName !== 'string' || !m.structName) {
throw new Error(`module ${i + 1}: structName required (upper camel case, e.g. UserInfo)`)
}
})
} Type guard
function hasStructName(m) {
return typeof m?.structName === 'string' && /^[A-Z][A-Za-z0-9]*$/.test(m.structName)
} Try / catch
try {
return await callTool('gva_execute', { executionPlan: plan })
} catch (e) {
const m = String(e.message).match(/模块 (\d+) 的 structName 不能为空/)
if (m) {
plan.modulesInfo[Number(m[1]) - 1].structName = toUpperCamel(tableName) // derive and retry
return await callTool('gva_execute', { executionPlan: plan })
}
throw e
} Prevention
- Derive structName from tableName via snake_case → UpperCamel conversion in your plan builder.
- Keep structName, humpPackageName and packageName consistent with one naming pass.
- Pre-validate module entries against the full required-field list before calling.
When it happens
Trigger: Calling gva_execute with needCreatedModules=true and a modulesInfo entry missing "structName" or passing an empty string — common when the LLM only filled package/tableName or used a lowercase/plain name that later got lost.
Common situations: LLM-generated plans omitting the struct name; clients mapping a different field name (e.g. modelName) into the payload; copy-pasted partial module entries from earlier rounds.
Understand the failure class
Background: "Missing required field" and "field is required" errors: why libraries reject payloads that omit mandatory fields — this error's family across 20 libraries.
Related errors
- 模块 %d 的 package 不能为空
- 执行计划验证失败: %v
- 参数错误:executionPlan 必须提供
- packageName 不能为空
- packageType 必须是 'package' 或 'plugin'
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/f370dace6100ee92.
Report an issue: GitHub.