flipped-aurora/gin-vue-admin · error

模块 %d 的 package 不能为空

Error message

模块 %d 的 package 不能为空

What it means

validateExecutionPlan (server/mcp/gva_execute.go:326) rejects an ExecutionPlan when a module in modulesInfo has an empty package field. The message indexes modules from 1 (模块 %d), so "模块 1" is the first element. The package field names which existing autocode package the module's code belongs to; without it, generated code cannot be placed.

Source

Thrown at server/mcp/gva_execute.go:326

		if plan.PackageInfo.Template != "package" && plan.PackageInfo.Template != "plugin" {
			return errors.New("packageInfo.template 必须是 'package' 或 'plugin'")
		}
		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)

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Locate the module at the reported index (1-based) in modulesInfo.
  2. Set its "package" field to the target package name (lowercase-leading, e.g. "userInfo").
  3. Run gva_analyze first and copy the packageName from an existing package in the snapshot.
  4. While editing, also supply the other required module fields (structName, tableName, description, abbreviation, packageName, humpPackageName, fields) to pass validation in one round.

Example fix

// before
"modulesInfo":[{"structName":"User","tableName":"users", ...}]
// after
"modulesInfo":[{"package":"user","structName":"User","tableName":"users", ...}]
Defensive patterns

Strategy: validation

Validate before calling

function validateModulePackage(modulesInfo) {
  return modulesInfo?.every((m, i) => {
    if (typeof m.package !== 'string' || !m.package) throw new Error(`module ${i + 1}: package required (lowercase-leading, from gva_analyze snapshot)`)
    return true
  })
}

Type guard

function hasPackage(m) {
  return typeof m?.package === 'string' && m.package.trim().length > 0
}

Try / catch

try {
  return await callTool('gva_execute', { executionPlan: plan })
} catch (e) {
  const m = String(e.message).match(/模块 (\d+) 的 package 不能为空/)
  if (m) {
    plan.modulesInfo[Number(m[1]) - 1].package = targetPackage // fill and retry
    return await callTool('gva_execute', { executionPlan: plan })
  }
  throw e
}

Prevention

When it happens

Trigger: Calling gva_execute with needCreatedModules=true and a modulesInfo entry lacking the "package" key or passing "package": "" — typically the LLM omitted it or confused it with packageName.

Common situations: LLM-generated plans that fill structName/tableName but skip package; confusion between the module's package field and packageName (file name) or the plan-level packageName; copying partial examples from older docs.

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


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