{"record":{"id":"fae6830b74fed079","repo":"golang/go","slug":"zip-writer-comment-too-long","errorCode":null,"errorMessage":"zip: Writer.Comment too long","messagePattern":"zip: Writer\\.Comment too long","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/archive/zip/writer.go","lineNumber":74,"sourceCode":"// It must be called before any data is written.\nfunc (w *Writer) SetOffset(n int64) {\n\tif w.cw.count != 0 {\n\t\tpanic(\"zip: SetOffset called after data was written\")\n\t}\n\tw.cw.count = n\n}\n\n// Flush flushes any buffered data to the underlying writer.\n// Calling Flush is not normally necessary; calling Close is sufficient.\nfunc (w *Writer) Flush() error {\n\treturn w.cw.w.(*bufio.Writer).Flush()\n}\n\n// SetComment sets the end-of-central-directory comment field.\n// It can only be called before [Writer.Close].\nfunc (w *Writer) SetComment(comment string) error {\n\tif len(comment) > uint16max {\n\t\treturn errors.New(\"zip: Writer.Comment too long\")\n\t}\n\tw.comment = comment\n\treturn nil\n}\n\n// Close finishes writing the zip file by writing the central directory.\n// It does not close the underlying writer.\nfunc (w *Writer) Close() error {\n\tif w.last != nil && !w.last.closed {\n\t\tif err := w.last.close(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tw.last = nil\n\t}\n\tif w.closed {\n\t\treturn errors.New(\"zip: writer closed twice\")\n\t}\n\tw.closed = true","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/archive/zip/writer.go#L56-L92","documentation":"Error \"zip: Writer.Comment too long\" thrown in golang/go.","triggerScenarios":"Thrown at src/archive/zip/writer.go:74 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}