{"record":{"id":"e54a3ac5002a0fd7","repo":"flipped-aurora/gin-vue-admin","slug":"page","errorCode":null,"errorMessage":"page为表单生成器!","messagePattern":"page为表单生成器!","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_package.go","lineNumber":35,"sourceCode":"\t\"github.com/flipped-aurora/gin-vue-admin/server/utils/ast\"\n\t\"github.com/flipped-aurora/gin-vue-admin/server/utils/autocode\"\n\t\"github.com/pkg/errors\"\n\t\"gorm.io/gorm\"\n)\n\nvar AutoCodePackage = new(autoCodePackage)\n\ntype autoCodePackage struct{}\n\n// Create 创建包信息\n// @author: [piexlmax](https://github.com/piexlmax)\n// @author: [SliverHorn](https://github.com/SliverHorn)\nfunc (s *autoCodePackage) Create(ctx context.Context, info *request.SysAutoCodePackageCreate) error {\n\tswitch {\n\tcase info.Template == \"\":\n\t\treturn errors.New(\"模板不能为空!\")\n\tcase info.Template == \"page\":\n\t\treturn errors.New(\"page为表单生成器!\")\n\tcase info.PackageName == \"\":\n\t\treturn errors.New(\"PackageName不能为空!\")\n\tcase token.IsKeyword(info.PackageName):\n\t\treturn errors.Errorf(\"%s为go的关键字!\", info.PackageName)\n\tcase info.Template == \"package\":\n\t\tif info.PackageName == \"system\" || info.PackageName == \"example\" {\n\t\t\treturn errors.New(\"不能使用已保留的package name\")\n\t\t}\n\tdefault:\n\t\tbreak\n\t}\n\tif !errors.Is(global.GVA_DB.Where(\"package_name = ? and template = ?\", info.PackageName, info.Template).First(&model.SysAutoCodePackage{}).Error, gorm.ErrRecordNotFound) {\n\t\treturn errors.New(\"存在相同PackageName\")\n\t}\n\tcreate := info.Create()\n\treturn global.GVA_DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error {\n\t\terr := tx.Create(&create).Error\n\t\tif err != nil {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_package.go#L17-L53","documentation":"In autoCodePackage.Create()'s validation switch, the case info.Template == \"page\" returns 'page为表单生成器!' — \"page\" is reserved for the form generator and is not a valid template for creating a package.","triggerScenarios":"Calling the package create API with template set to \"page\" instead of a valid package template value.","commonSituations":"Client sends the currently selected form-generator template name into the package creation form; copy-pasted payload from a page-template request; confusion between page templates and package templates in the auto-code UI.","solutions":["Change the template value to a valid package template such as \"package\".","Do not reuse the form-generator (page) template for package creation; create pages through the page/form-generator flow instead.","Fix the frontend to send the package-specific template when in package mode.","Review the SysAutoCodePackageCreate request schema for allowed template values."],"exampleFix":"// before\nawait api.createPackage({ template: 'page', packageName: 'order' })\n// after\nawait api.createPackage({ template: 'package', packageName: 'order' })","handlingStrategy":"validation","validationCode":"// restrict template choices for package creation\nconst allowed = ['package']\nif (!allowed.includes(form.template)) {\n  ElMessage.warning('包模板仅支持 package，page 属于表单生成器')\n  return\n}\nawait api.createPackage(form)","typeGuard":null,"tryCatchPattern":"try {\n  await svc.Create(ctx, info)\n} catch (err) {\n  if (err.Error() == \"page为表单生成器!\") {\n    // redirect user to the page/form-generator flow instead\n  } else {\n    return err\n  }\n}","preventionTips":["Use a dropdown of allowed template values instead of free text","Keep page-template requests on the form-generator endpoints","Document the distinction between package and page templates","Test both create flows to catch mixed-up template values"],"tags":["autocode","validation","invalid-argument"],"backgroundTag":"invalid-argument-value","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}