{"record":{"id":"70fa832be832d309","repo":"golang/go","slug":"zip-size-cannot-be-negative","errorCode":null,"errorMessage":"zip: size cannot be negative","messagePattern":"zip: size cannot be negative","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/archive/zip/reader.go","lineNumber":108,"sourceCode":"\t\treturn nil, err\n\t}\n\tr.f = f\n\treturn r, err\n}\n\n// NewReader returns a new [Reader] reading from r, which is assumed to\n// have the given size in bytes.\n//\n// If any file inside the archive uses a non-local name\n// (as defined by [filepath.IsLocal]) or a name containing backslashes\n// and the GODEBUG environment variable contains `zipinsecurepath=0`,\n// NewReader returns the reader with an [ErrInsecurePath] error.\n// A future version of Go may introduce this behavior by default.\n// Programs that want to accept non-local names can ignore\n// the [ErrInsecurePath] error and use the returned reader.\nfunc NewReader(r io.ReaderAt, size int64) (*Reader, error) {\n\tif size < 0 {\n\t\treturn nil, errors.New(\"zip: size cannot be negative\")\n\t}\n\tzr := new(Reader)\n\tvar err error\n\tif err = zr.init(r, size); err != nil && err != ErrInsecurePath {\n\t\treturn nil, err\n\t}\n\treturn zr, err\n}\n\nfunc (r *Reader) init(rdr io.ReaderAt, size int64) error {\n\tend, baseOffset, err := readDirectoryEnd(rdr, size)\n\tif err != nil {\n\t\treturn err\n\t}\n\tr.r = rdr\n\tr.baseOffset = baseOffset\n\t// Since the number of directory records is not validated, it is not\n\t// safe to preallocate r.File without first checking that the specified","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/archive/zip/reader.go#L90-L126","documentation":"Error \"zip: size cannot be negative\" thrown in golang/go.","triggerScenarios":"Thrown at src/archive/zip/reader.go:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}