{"record":{"id":"b69e45ff91f79b73","repo":"flipped-aurora/gin-vue-admin","slug":"w-b69e45","errorCode":null,"errorMessage":"创建临时文件失败: %w","messagePattern":"创建临时文件失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/service/system/sys_skills.go","lineNumber":449,"sourceCode":"\n\trealDownloadURL := strings.TrimSpace(meta.Data.URL)\n\tif realDownloadURL == \"\" {\n\t\treturn errors.New(\"下载结果缺少 url\")\n\t}\n\n\tzipResp, err := http.Get(realDownloadURL)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"下载压缩包失败: %w\", err)\n\t}\n\tdefer zipResp.Body.Close()\n\n\tif zipResp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"下载压缩包失败, HTTP状态码: %d\", zipResp.StatusCode)\n\t}\n\n\ttmpFile, err := os.CreateTemp(\"\", \"gva-skill-*.zip\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"创建临时文件失败: %w\", err)\n\t}\n\ttmpPath := tmpFile.Name()\n\tdefer os.Remove(tmpPath)\n\n\tif _, err = io.Copy(tmpFile, zipResp.Body); err != nil {\n\t\ttmpFile.Close()\n\t\treturn fmt.Errorf(\"保存技能包失败: %w\", err)\n\t}\n\ttmpFile.Close()\n\n\tif err = extractZipToDir(tmpPath, skillsDir); err != nil {\n\t\treturn fmt.Errorf(\"解压技能包失败: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc extractZipToDir(zipPath, destDir string) error {","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/service/system/sys_skills.go#L431-L467","documentation":"os.CreateTemp failed to create the temporary file used to stage the downloaded skill zip. This is a local filesystem error: os.CreateTemp fails when the temp directory (TMPDIR or /tmp) is unwritable, doesn't exist, or the system is out of inodes/space.","triggerScenarios":"Calling DownloadOnlineSkill on a server whose TMPDIR points to a nonexistent/unwritable directory, /tmp is mounted read-only or full (no space left on device), or the process user lacks write permission to the temp dir.","commonSituations":"Containers with read-only root filesystems and no writable tmp mount; disk full after large log accumulation; hardened tmp permissions (sticky bit/ownership); TMPDIR misconfiguration in systemd units or k8s pods.","solutions":["Check TMPDIR and /tmp: ls -ld /tmp; touch /tmp/probe as the server user","Free disk space / clean the filesystem if 'no space left on device'","Mount a writable emptyDir/tmp volume in containerized deployments","Verify the wrapped error: permission denied vs no space vs no such file or directory"],"exampleFix":"// pin a known-writable temp dir in containerized deployments\n// before (relies on TMPDIR)\ntmpFile, err := os.CreateTemp(\"\", \"gva-skill-*.zip\")\n// after\ntmpFile, err := os.CreateTemp(\"/var/tmp/gva\", \"gva-skill-*.zip\") // dir pre-created with correct perms","handlingStrategy":"validation","validationCode":"probe := filepath.Join(os.TempDir(), \".gva-probe\")\nif f, err := os.Create(probe); err != nil {\n    // temp dir unwritable/full — fix before attempting downloads\n} else { f.Close(); os.Remove(probe) }","typeGuard":null,"tryCatchPattern":"if err := DownloadOnlineSkill(ctx, req); err != nil && strings.Contains(err.Error(), \"创建临时文件失败\") {\n    // check TMPDIR writability and disk space; surface a storage alert\n}","preventionTips":["Ensure TMPDIR (or /tmp) exists, is writable by the service user, and has free space","Mount a writable tmp volume in read-only container filesystems","Alert on disk usage; clean stale temp files (gva-skill-*.zip leftovers)","Pin an explicit temp directory with correct permissions in deployments"],"tags":["go","filesystem","temp-file","disk"],"backgroundTag":"temp-file-create-failed","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}