{"record":{"id":"37164d811777dc9b","repo":"flipped-aurora/gin-vue-admin","slug":"staging-w-37164d","errorCode":null,"errorMessage":"写入自动代码 staging 失败: %w","messagePattern":"写入自动代码 staging 失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/auto_code_task.go","lineNumber":142,"sourceCode":"\t\tswitch {\n\t\tcase statErr == nil:\n\t\t\tif !stat.Mode().IsRegular() {\n\t\t\t\treturn nil, fmt.Errorf(\"自动代码目标不是普通文件: %s\", target)\n\t\t\t}\n\t\t\tbefore, readErr := os.ReadFile(target)\n\t\t\tif readErr != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"读取自动代码目标 %s 失败: %w\", target, readErr)\n\t\t\t}\n\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))","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/auto_code_task.go#L124-L160","documentation":"Returned when writing the staged copy of the new file content via replaceAutoCodeFileAtomically fails. The staging directory was created under layout.root with os.MkdirTemp, so failures usually indicate disk-space exhaustion, staging-dir permission problems, or I/O errors. The original writeErr is wrapped with %w for errors.Is inspection.","triggerScenarios":"Disk full (ENOSPC) when writing staged content; the staging directory was removed concurrently by a cleanup/tmp sweeper; write/permission error on the temp file; I/O error on the underlying volume.","commonSituations":"CI runners or containers with small ephemeral disks; tmpwatch/systemd-tmpfiles or manual cleanup deleting .autocode-staging-* directories mid-run; read-only root filesystems in hardened containers; quota limits on the repo volume.","solutions":["Free disk space on the volume holding the project root (check `df -h`); staged content plus existing files must fit.","Ensure nothing concurrently deletes the staging directory (exclude .autocode-staging-* from tmp cleaners/cron jobs).","Verify the server process has write permission on layout.root so MkdirTemp and staged writes succeed.","Retry after transient I/O failures; inspect the wrapped cause with errors.Is(err, syscall.ENOSPC) etc."],"exampleFix":"// before: disk full\n$ df -h /workspace  =>  100% used\n// after\n$ docker system prune  # or delete build artifacts\n$ df -h /workspace  =>  40% used\n# retry the autocode task","handlingStrategy":"retry","validationCode":"func canWriteStaging(root string) error {\n  dir, err := os.MkdirTemp(root, \".autocode-staging-check-\")\n  if err != nil {\n    return fmt.Errorf(\"cannot create staging dir under %s: %w\", root, err)\n  }\n  probe := filepath.Join(dir, \"probe\")\n  if err := os.WriteFile(probe, []byte(\"ok\"), 0o666); err != nil {\n    os.RemoveAll(dir)\n    return fmt.Errorf(\"cannot write into staging dir: %w\", err)\n  }\n  return os.RemoveAll(dir)\n}","typeGuard":null,"tryCatchPattern":"// Retry once after transient staging write failures, after freeing space\nvar err error\nfor i := 0; i < 2; i++ {\n  err = svc.Create(c, req)\n  if err == nil || !errors.Is(err, syscall.ENOSPC) {\n    break\n  }\n  freeDiskSpaceOrAlert()\n}\nif err != nil {\n  return err\n}","preventionTips":["Monitor free disk space on the volume hosting the project root before running generation.","Exclude .autocode-staging-* directories from tmp cleaners, cron sweeps, and git hooks.","Ensure the server process has write permission on the project root and the volume is not mounted read-only.","Retry failed generation tasks once after transient I/O errors before escalating."],"tags":["go","filesystem","disk-full","staging-write","autocode"],"backgroundTag":"disk-full-write-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}