{"record":{"id":"22ade0da87f65fa5","repo":"moonD4rk/HackBrowserData","slug":"write-bom-w","errorCode":null,"errorMessage":"write BOM: %w","messagePattern":"write BOM: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"output/output.go","lineNumber":160,"sourceCode":"\t\treturn nil\n\t}\n\n\tfilename := fmt.Sprintf(\"%s.%s\", category, o.formatter.ext())\n\tpath := filepath.Join(o.dir, filename)\n\n\tf, err := os.OpenFile(filepath.Clean(path), os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o600)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create %s: %w\", filename, err)\n\t}\n\tdefer func() {\n\t\tif cerr := f.Close(); cerr != nil && err == nil {\n\t\t\terr = fmt.Errorf(\"close %s: %w\", filename, cerr)\n\t\t}\n\t}()\n\n\tif strings.HasSuffix(path, \".csv\") {\n\t\tif _, err := f.Write(utf8BOM); err != nil {\n\t\t\treturn fmt.Errorf(\"write BOM: %w\", err)\n\t\t}\n\t}\n\n\tif _, err := f.Write(buf.Bytes()); err != nil {\n\t\treturn fmt.Errorf(\"write %s: %w\", filename, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":142,"sourceCodeEnd":169,"githubUrl":"https://github.com/moonD4rk/HackBrowserData/blob/0503d04d7a8d0379d060268a74f1b149e5a0aad5/output/output.go#L142-L169","documentation":"For CSV output, writeFile writes a 3-byte UTF-8 BOM before the formatted content so Excel detects UTF-8. This error wraps a failed f.Write of that BOM, meaning even the first bytes of the file could not be written — the output file will be missing or invalid.","triggerScenarios":"f.Write(utf8BOM) returned a short write or error right after a successful OpenFile: disk full, handle closed/invalid, or the file descriptor became unwritable between open and write.","commonSituations":"Disk filled between file creation and write; file opened on a flaky network/USB volume; extremely constrained environments (containers with tiny tmpfs output dirs).","solutions":["Free disk space on the output volume and retry.","Write output to a reliable local filesystem rather than network/removable mounts.","Verify the file handle is valid (no early Close) and re-run the extraction.","Check container/volume size limits if writing into tmpfs or small volumes."],"exampleFix":"// before\nif _, err := f.Write(utf8BOM); err != nil {\n\treturn fmt.Errorf(\"write BOM: %w\", err)\n}\n// after: check the short-write case explicitly\nif n, err := f.Write(utf8BOM); err != nil || n != len(utf8BOM) {\n\treturn fmt.Errorf(\"write BOM: wrote %d bytes: %w\", n, err)\n}","handlingStrategy":"try-catch","validationCode":"if st, err := os.Stat(outputDir); err == nil {\n\t_ = st // also verify volume free space > expected output size before writing\n}","typeGuard":null,"tryCatchPattern":"if err := w.Write(); err != nil {\n\tif strings.Contains(err.Error(), \"write BOM\") {\n\t\t// handle write failed immediately after open: check disk/handle, retry\n\t}\n}","preventionTips":["Monitor disk space; fail fast before extraction on low space.","Avoid tmpfs/small volumes for output.","Keep the output path on stable local storage.","Handle short writes explicitly in custom write paths."],"tags":["filesystem","csv","utf8","output"],"backgroundTag":"file-write-failed","analyzedSha":"0503d04d7a8d0379d060268a74f1b149e5a0aad5","analyzedAt":"2026-09-06T13:38:28.707Z","contentChangedAt":"2026-09-06T13:38:28.707Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}