{"record":{"id":"19a9d9444729cb2d","repo":"dgraph-io/badger","slug":"error-compression-type-s-invalid","errorCode":null,"errorMessage":"ERROR: compression type (%s) invalid","messagePattern":"ERROR: compression type \\((.+?)\\) invalid","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"options.go","lineNumber":248,"sourceCode":"\tif len(cStrSplit) == 2 {\n\t\tlevel, err = strconv.Atoi(cStrSplit[1])\n\t\ty.Check(err)\n\t\tif level <= 0 {\n\t\t\treturn 0, 0,\n\t\t\t\tfmt.Errorf(\"ERROR: compression level(%v) must be greater than zero\", level)\n\t\t}\n\t} else if len(cStrSplit) > 2 {\n\t\treturn 0, 0, fmt.Errorf(\"ERROR: Invalid badger.compression argument\")\n\t}\n\tswitch cType {\n\tcase \"zstd\":\n\t\treturn options.ZSTD, level, nil\n\tcase \"snappy\":\n\t\treturn options.Snappy, 0, nil\n\tcase \"none\":\n\t\treturn options.None, 0, nil\n\t}\n\treturn 0, 0, fmt.Errorf(\"ERROR: compression type (%s) invalid\", cType)\n}\n\n// generateSuperFlag generates an identical SuperFlag string from the provided Options.\nfunc generateSuperFlag(options Options) string {\n\tsuperflag := \"\"\n\tv := reflect.ValueOf(&options).Elem()\n\toptionsStruct := v.Type()\n\tfor i := 0; i < v.NumField(); i++ {\n\t\tif field := v.Field(i); field.CanInterface() {\n\t\t\tname := strings.ToLower(optionsStruct.Field(i).Name)\n\t\t\tkind := v.Field(i).Kind()\n\t\t\tswitch kind {\n\t\t\tcase reflect.Bool:\n\t\t\t\tsuperflag += name + \"=\"\n\t\t\t\tsuperflag += fmt.Sprintf(\"%v; \", field.Bool())\n\t\t\tcase reflect.Int, reflect.Int64:\n\t\t\t\tsuperflag += name + \"=\"\n\t\t\t\tsuperflag += fmt.Sprintf(\"%v; \", field.Int())","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/options.go#L230-L266","documentation":"After parsing an optional level, the compression type token must be one of \"zstd\", \"snappy\", or \"none\". This error is returned when the type token matches none of those, indicating an unsupported or misspelled compression name.","triggerScenarios":"Passing badger.compression=gzip, badger.compression=ZSTD (case-sensitivity in the switch), or any misspelled/renamed type into Options.FromSuperFlag.","commonSituations":"Users assuming other codecs (gzip, lz4) are supported; config written for a different library; shell scripts uppercasing values.","solutions":["Use one of the supported values exactly: none, snappy, or zstd","Check for case/whitespace issues in the config source; normalize the value before parsing","If another codec is required, check whether the installed badger version supports it or implement a custom path upstream"],"exampleFix":"// before\nbadger.compression=gzip\n// after\nbadger.compression=zstd:1","handlingStrategy":"validation","validationCode":"func knownCompressionType(v string) bool {\n    t := strings.SplitN(v, \":\", 2)[0]\n    switch t {\n    case \"zstd\", \"snappy\", \"none\":\n        return true\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":"opts, err := badger.DefaultOptions(dir).FromSuperFlag(cfg)\nif err != nil && strings.Contains(err.Error(), \"compression type\") {\n    return fmt.Errorf(\"unsupported compression %q; use none|snappy|zstd\", cfg)\n}","preventionTips":["Restrict config schema to the three supported types (none, snappy, zstd)","Beware case changes from shell/env processing; normalize to lowercase","Check installed badger version before assuming extra codecs exist"],"tags":["badger","configuration","compression","superflag"],"backgroundTag":"invalid-config-value","analyzedSha":"2a001d466f6b71a917319a1db41f99860e16e269","analyzedAt":"2026-09-05T13:00:02.264Z","contentChangedAt":"2026-09-05T13:00:02.264Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}