{"record":{"id":"3db8012958688658","repo":"flipped-aurora/gin-vue-admin","slug":"error-3db801","errorCode":null,"errorMessage":"自动代码任务提交参数不能为空","messagePattern":"自动代码任务提交参数不能为空","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_task.go","lineNumber":151,"sourceCode":"\t\t\tfile.Existed = true\n\t\t\tfile.Mode = stat.Mode().Perm()\n\t\t\tfile.BeforeContent = before\n\t\t\tfile.BeforeHash = hashAutoCodeContent(before)\n\t\tcase errors.Is(statErr, fs.ErrNotExist):\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"检查自动代码目标 %s 失败: %w\", target, statErr)\n\t\t}\n\t\tif writeErr := replaceAutoCodeFileAtomically(file.StagedPath, content, file.Mode); writeErr != nil {\n\t\t\treturn nil, fmt.Errorf(\"写入自动代码 staging 失败: %w\", writeErr)\n\t\t}\n\t\ttask.files = append(task.files, file)\n\t}\n\treturn task, nil\n}\n\nfunc commitAutoCodeFileTask(task *autoCodeFileTask, publish autoCodeFilePublisher, persist func() error) error {\n\tif task == nil || publish == nil || persist == nil {\n\t\treturn errors.New(\"自动代码任务提交参数不能为空\")\n\t}\n\tdefer task.cleanup()\n\n\tbackendApplied, err := task.apply(autoCodeTaskBackend, publish)\n\tif err != nil {\n\t\treturn joinAutoCodeRollbackError(err, task.rollback(backendApplied))\n\t}\n\tif err = persist(); err != nil {\n\t\treturn joinAutoCodeRollbackError(err, task.rollback(backendApplied))\n\t}\n\tfrontendApplied, err := task.apply(autoCodeTaskFrontend, publish)\n\tif err != nil {\n\t\treturn joinAutoCodeRollbackError(\n\t\t\tfmt.Errorf(\"数据库已提交，前端文件发布失败: %w\", err),\n\t\t\ttask.rollback(frontendApplied),\n\t\t)\n\t}\n\treturn nil","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_task.go#L133-L169","documentation":"commitAutoCodeFileTask validates its inputs up front: a non-nil task, a non-nil publish function, and a non-nil persist callback. If any is missing it returns \"自动代码任务提交参数不能为空\" (commit parameters cannot be empty) instead of proceeding with a partially initialized task.","triggerScenarios":"Calling commitAutoCodeFileTask with a nil *autoCodeFileTask, nil publish publisher, or nil persist function — typically a programming error in wiring the commit pipeline or a test passing partial fixtures.","commonSituations":"Refactoring the publish/persist call chain and forgetting to pass a callback; constructing tasks manually in tests; error paths where an earlier prepare failed but commit is still invoked.","solutions":["Ensure prepareAutoCodeFileTask succeeded and returned a non-nil task before committing.","Pass real publish and persist implementations (or valid fakes in tests).","Guard call sites: skip commit when an earlier step already returned an error.","Check for refactoring regressions where a callback parameter was dropped."],"exampleFix":"// before\nerr := commitAutoCodeFileTask(task, nil, persist)\n// after\nerr := commitAutoCodeFileTask(task, publisher, persist)","handlingStrategy":"validation","validationCode":"if task == nil || publish == nil || persist == nil {\n    return errors.New(\"commit 前置校验失败: task/publish/persist 均不能为 nil\")\n}\n// safe to commit","typeGuard":"func taskReady(task *autoCodeFileTask) bool {\n    return task != nil && len(task.targets) > 0\n}","tryCatchPattern":"if err := commitAutoCodeFileTask(task, publisher, persistFn); err != nil {\n    if err.Error() == \"自动代码任务提交参数不能为空\" {\n        return fmt.Errorf(\"commit 管道未正确装配 (nil 参数): %w\", err)\n    }\n    return err\n}","preventionTips":["Always obtain task from prepareAutoCodeFileTask; never construct it manually.","Check the error of the prepare step before calling commit.","Keep publish/persist wiring in one factory function to avoid dropped parameters.","Add nil-parameter table tests when refactoring the commit signature."],"tags":["autocode","nil-check","validation","go"],"backgroundTag":"nil-argument","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}