flipped-aurora/gin-vue-admin · error

autocode module is empty

Error message

autocode module is empty

What it means

Rewriting a sub-plugin's Go import paths requires the AutoCode module name from configuration (the Go module of generated code). prepareSubPluginSource reads `global.GVA_CONFIG.AutoCode.Module` and, when it is empty or whitespace, cannot compute the old/new import prefixes and throws this error before any file rewriting happens.

Source

Thrown at server/service/system/auto_code_plugin.go:353

	if _, err = os.Stat(target); err == nil {
		return errors.New("plugin already exists")
	} else if !os.IsNotExist(err) {
		return err
	}
	return nil
}

func copyPluginArchive(sourceRoot, destinationRoot string) error {
	if err := os.MkdirAll(destinationRoot, 0755); err != nil {
		return err
	}
	return cp.Copy(sourceRoot, destinationRoot, cp.Options{Skip: skipMacSpecialDocument})
}

func prepareSubPluginSource(childPath, parentPlugin, childPlugin string) error {
	module := strings.TrimSpace(global.GVA_CONFIG.AutoCode.Module)
	if module == "" {
		return errors.New("autocode module is empty")
	}
	oldImportPrefix := fmt.Sprintf("%s/plugin/%s", module, childPlugin)
	newImportPrefix := fmt.Sprintf("%s/plugin/%s/subPlugin/%s", module, parentPlugin, childPlugin)
	err := filepath.Walk(childPath, func(path string, info os.FileInfo, walkErr error) error {
		if walkErr != nil {
			return walkErr
		}
		if info.IsDir() || filepath.Ext(path) != ".go" {
			return nil
		}
		return rewriteGoImportPaths(path, oldImportPrefix, newImportPrefix)
	})
	if err != nil {
		return err
	}
	entryPath := filepath.Join(childPath, "plugin.go")
	if err = suppressSubPluginSelfRegistration(entryPath); err != nil {
		return err

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Set `autoCode.module` in the server config to the actual Go module path of your generated code (e.g. github.com/org/project).
  2. Restart the server so the new config value is loaded into global.GVA_CONFIG.
  3. If config is injected via environment variables, confirm the variable mapping for the module key is present and non-empty.

Example fix

// before (config.yaml)
autoCode:
  module: ""
// after
autoCode:
  module: "github.com/your-org/your-project"
Defensive patterns

Strategy: validation

Validate before calling

if (strings.TrimSpace(global.GVA_CONFIG.AutoCode.Module) == "") {
  return errors.New("autoCode.module must be set before installing sub-plugins")
}

Try / catch

if err := installSubPlugin(parent, child); err != nil {
  if strings.Contains(err.Error(), "autocode module is empty") {
    log.Fatal("set autoCode.module in config and restart the server")
  }
  return err
}

Prevention

When it happens

Trigger: Calling the sub-plugin install API while `autoCode.module` in the server config is unset, empty string, or only whitespace; running with a config file that omits the autoCode section entirely.

Common situations: Fresh deployment where the autoCode config block was never filled in; config trimmed down for production and the module key dropped; environment-variable-driven config overriding the value to empty; copying a config template without editing it.

Related errors


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