{"record":{"id":"5b0bde46769715f8","repo":"owasp-amass/amass","slug":"file-cannot-be-checked-for-compression","errorCode":null,"errorMessage":"file cannot be checked for compression","messagePattern":"file cannot be checked for compression","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/wordlist.go","lineNumber":116,"sourceCode":"\t\treturn nil, errors.New(\"the file is empty\")\n\t}\n\n\tif gz, err := getGzipReader(file, absPath); err == nil {\n\t\tdefer func() { _ = gz.Close() }()\n\t\treader = gz\n\t}\n\n\treturn GetWordList(reader)\n}\n\nfunc getGzipReader(file *os.File, absPath string) (*gzip.Reader, error) {\n\tfinfo, err := file.Stat()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tif finfo.Size() < 512 {\n\t\treturn nil, errors.New(\"file cannot be checked for compression\")\n\t}\n\n\t// We need to determine if this is a gzipped file or a plain text file, so we\n\t// first read the first 512 bytes to pass them down to http.DetectContentType\n\t// for mime detection. The file is rewinded before passing it along to the\n\t// next reader\n\thead := make([]byte, 512)\n\tif _, err = file.Read(head); err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading the first 512 bytes from %s: %s\", absPath, err)\n\t}\n\tif _, err = file.Seek(0, 0); err != nil {\n\t\treturn nil, fmt.Errorf(\"error rewinding the file %s: %s\", absPath, err)\n\t}\n\n\t// Read the file as gzip if it's actually compressed\n\tif mt := http.DetectContentType(head); mt == \"application/gzip\" || mt == \"application/x-gzip\" {\n\t\tgzReader, err := gzip.NewReader(file)\n\t\tif err != nil {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/config/wordlist.go#L98-L134","documentation":"getGzipReader stats the file to decide whether compression detection is possible; the detection routine needs at least 512 bytes (the http.DetectContentType sniff size). Files smaller than 512 bytes cannot be reliably checked for gzip content, so this error is returned rather than guessing the format.","triggerScenarios":"Calling GetListFromFile on a wordlist smaller than 512 bytes (e.g. a handful of subdomain entries in a plain-text file), causing getGzipReader to hit finfo.Size() < 512 and fail.","commonSituations":"Testing with a tiny wordlist of a few lines, a partially written file, or an intentionally minimal custom list — common in CI or quick experiments.","solutions":["Pad or use a wordlist file of at least 512 bytes (add more entries).","Combine several small lists into one larger file.","Skip compression detection by supplying a known plain-text path if the library supports it.","Check the file size before calling and warn the user."],"exampleFix":"// before\ndata := []byte(\"a.com\\nb.com\\n\") // 11 bytes\n_ = os.WriteFile(\"small.txt\", data, 0644)\n// after\ndata := bytes.Repeat([]byte(\"a.com\\n\"), 100) // > 512 bytes\n_ = os.WriteFile(\"wordlist.txt\", data, 0644)","handlingStrategy":"validation","validationCode":"info, err := os.Stat(path)\nif err != nil { return err }\nif info.Size() < 512 { return fmt.Errorf(\"wordlist %s is smaller than 512 bytes; compression cannot be detected\", path) }","typeGuard":null,"tryCatchPattern":"list, err := GetListFromFile(path)\nif err != nil {\n    if strings.Contains(err.Error(), \"cannot be checked for compression\") {\n        // pad the wordlist to >=512 bytes or concatenate with a larger list\n    }\n    return err\n}","preventionTips":["Use wordlists larger than 512 bytes in tests and CI.","Warn users about tiny wordlists at startup.","Concatenate small lists before use.","Know the 512-byte sniff threshold when creating custom lists."],"tags":["file","compression","gzip"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}