{"record":{"id":"5980bb1dea004969","repo":"dgraph-io/badger","slug":"errzerobandwidth","errorCode":"ErrZeroBandwidth","errorMessage":"Bandwidth must be greater than zero","messagePattern":"Bandwidth must be greater than zero","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":79,"sourceCode":"\n\t// ErrInvalidRequest is returned if the user request is invalid.\n\tErrInvalidRequest = stderrors.New(\"Invalid request\")\n\n\t// ErrManagedTxn is returned if the user tries to use an API which isn't\n\t// allowed due to external management of transactions, when using ManagedDB.\n\tErrManagedTxn = stderrors.New(\n\t\t\"Invalid API request. Not allowed to perform this action using ManagedDB\")\n\n\t// ErrNamespaceMode is returned if the user tries to use an API which is allowed only when\n\t// NamespaceOffset is non-negative.\n\tErrNamespaceMode = stderrors.New(\n\t\t\"Invalid API request. Not allowed to perform this action when NamespaceMode is not set.\")\n\n\t// ErrInvalidDump if a data dump made previously cannot be loaded into the database.\n\tErrInvalidDump = stderrors.New(\"Data dump cannot be read\")\n\n\t// ErrZeroBandwidth is returned if the user passes in zero bandwidth for sequence.\n\tErrZeroBandwidth = stderrors.New(\"Bandwidth must be greater than zero\")\n\n\t// ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows\n\tErrWindowsNotSupported = stderrors.New(\"Read-only mode is not supported on Windows\")\n\n\t// ErrPlan9NotSupported is returned when opt.ReadOnly is used on Plan 9\n\tErrPlan9NotSupported = stderrors.New(\"Read-only mode is not supported on Plan 9\")\n\n\t// ErrTruncateNeeded is returned when the value log gets corrupt, and requires truncation of\n\t// corrupt data to allow Badger to run properly.\n\tErrTruncateNeeded = stderrors.New(\n\t\t\"Log truncate required to run DB. This might result in data loss\")\n\n\t// ErrBlockedWrites is returned if the user called DropAll. During the process of dropping all\n\t// data from Badger, we stop accepting new writes, by returning this error.\n\tErrBlockedWrites = stderrors.New(\"Writes are blocked, possibly due to DropAll or Close\")\n\n\t// ErrNilCallback is returned when subscriber's callback is nil.\n\tErrNilCallback = stderrors.New(\"Callback cannot be nil\")","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/errors.go#L61-L97","documentation":"ErrZeroBandwidth is returned when a Sequence is created with a bandwidth of zero. Bandwidth controls how many sequence values Badger leases in advance; zero would make the sequence unusable, so GetSequence validates it (db.go:1439). Defined in errors.go.","triggerScenarios":"db.GetSequence(key, 0) — bandwidth == 0 at db.go:1439.","commonSituations":"Loading bandwidth from config where the value defaults to 0; computing bandwidth as a product that evaluates to zero; misunderstanding that bandwidth must be a positive integer.","solutions":["Pass a positive bandwidth, e.g. db.GetSequence(key, 100)","Validate config-supplied bandwidth > 0 with a fallback default before calling GetSequence","Use bandwidth=1 only if strict per-call allocation is intended — never 0"],"exampleFix":"// before\nseq, err := db.GetSequence([]byte(\"seq\"), cfg.Bandwidth)\n// after\nbandwidth := cfg.Bandwidth\nif bandwidth == 0 {\n\tbandwidth = 100\n}\nseq, err := db.GetSequence([]byte(\"seq\"), bandwidth)","handlingStrategy":"validation","validationCode":"if bandwidth <= 0 { return errors.New(\"bandwidth must be > 0\") }","typeGuard":null,"tryCatchPattern":"seq, err := db.GetSequence(key, bw)\nif errors.Is(err, ErrZeroBandwidth) {\n\treturn fmt.Errorf(\"config: sequence.bandwidth must be a positive integer\")\n}","preventionTips":["Validate config values at startup before opening the DB","Default bandwidth to a sane positive value when unset","Use integers, never ratios, for bandwidth"],"tags":["badger","sequence","validation","configuration"],"backgroundTag":"invalid-argument","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"}