{"record":{"id":"79f7edd075f6a92e","repo":"golang/go","slug":"zip-cannot-add-non-regular-file","errorCode":null,"errorMessage":"zip: cannot add non-regular file","messagePattern":"zip: cannot add non-regular file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/archive/zip/writer.go","lineNumber":576,"sourceCode":"}\n\n// AddFS adds the files from fs.FS to the archive.\n// It walks the directory tree starting at the root of the filesystem\n// adding each file to the zip using deflate while maintaining the directory structure.\nfunc (w *Writer) AddFS(fsys fs.FS) error {\n\treturn fs.WalkDir(fsys, \".\", func(name string, d fs.DirEntry, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif name == \".\" {\n\t\t\treturn nil\n\t\t}\n\t\tinfo, err := d.Info()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif !d.IsDir() && !info.Mode().IsRegular() {\n\t\t\treturn errors.New(\"zip: cannot add non-regular file\")\n\t\t}\n\t\th, err := FileInfoHeader(info)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\th.Name = name\n\t\tif d.IsDir() {\n\t\t\th.Name += \"/\"\n\t\t}\n\t\th.Method = Deflate\n\t\tfw, err := w.CreateHeader(h)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif d.IsDir() {\n\t\t\treturn nil\n\t\t}\n\t\tf, err := fsys.Open(name)","sourceCodeStart":558,"sourceCodeEnd":594,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/archive/zip/writer.go#L558-L594","documentation":"Error \"zip: cannot add non-regular file\" thrown in golang/go.","triggerScenarios":"Thrown at src/archive/zip/writer.go:576 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-12T08:17:17.861Z"}