{"record":{"id":"cc9678f23bb25bc4","repo":"ffuf/ffuf","slug":"could-not-write-json-data-to-audit-log-s","errorCode":null,"errorMessage":"could not write json data to audit log: %s","messagePattern":"could not write json data to audit log: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/output/audit.go","lineNumber":49,"sourceCode":"\tlogger.lock.Lock()\n\tdefer logger.lock.Unlock()\n\n\td := struct {\n\t\tType string\n\t\tData interface{}\n\t}{\n\t\treflect.TypeOf(data).String(),\n\t\tdata,\n\t}\n\n\tj, err := json.Marshal(d)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not marshal json data: %s\", err)\n\t}\n\n\t_, err = logger.file.Write(j)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not write json data to audit log: %s\", err)\n\t}\n\n\t_, err = logger.file.Write([]byte(\"\\n\"))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not write newline to underlying io.Writer: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":31,"sourceCodeEnd":59,"githubUrl":"https://github.com/ffuf/ffuf/blob/33c67d28c85b94589d029b3bcaff205a40cee9c4/pkg/output/audit.go#L31-L59","documentation":"After successfully marshaling the audit record, Write writes the JSON bytes to the underlying audit log file. If that file Write call fails, the record is lost and this error is returned wrapping the underlying I/O error.","triggerScenarios":"Calling Write when logger.file.Write(j) returns an error: the file handle is closed, the disk is full, the file was removed, permissions changed, or the underlying writer is otherwise broken.","commonSituations":"Disk quota/full disk on long fuzzing runs; the audit log file deleted or rotated while ffuf is running; writing to a path the process lacks write permission for; a custom io.Writer that errors (e.g. network log sink dropped).","solutions":["Read the wrapped %s error to identify the OS-level cause (ENOSPC, EACCES, EBADF, etc.).","Verify the audit log file still exists, is writable, and the disk has free space (df / check quota).","Reopen or recreate the audit log file with correct permissions and retry, or point -audit-log to a different writable location.","If wrapping a custom writer, check that writer's health/connectivity before logging."],"exampleFix":"// before\nlogger, _ := NewAuditLogger(\"/mnt/readonly/audit.json\") // writes fail with EACCES\n// after\nlogger, _ := NewAuditLogger(\"/var/log/ffuf/audit.json\") // writable path","handlingStrategy":"try-catch","validationCode":"if st, err := logger.file.Stat(); err != nil {\n    return fmt.Errorf(\"audit log unavailable: %w\", err)\n} // plus check disk space before long runs","typeGuard":null,"tryCatchPattern":"if err := logger.Write(data); err != nil {\n    var perr *fs.PathError\n    if errors.As(err, &perr) {\n        log.Printf(\"audit log I/O failure (%s): reopen log\", perr.Err)\n        logger = reopenAuditLogger(alternatePath)\n    }\n    return err\n}","preventionTips":["Monitor disk space/quota on hosts running long ffuf jobs.","Do not delete or rotate the audit log while the process holds it open; use copytruncate-style rotation.","Run with write permission on the -audit-log path; verify with a touch test first.","If using a custom io.Writer sink, wrap it with error handling/reconnect logic."],"tags":["ffuf","io","logging","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"33c67d28c85b94589d029b3bcaff205a40cee9c4","analyzedAt":"2026-09-04T18:24:34.068Z","contentChangedAt":"2026-09-04T18:24:34.068Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}