{"record":{"id":"d22d19c3635b9bb7","repo":"AlistGo/alist","slug":"chunk-size-must-be-positive","errorCode":null,"errorMessage":"chunk_size must be positive","messagePattern":"chunk_size must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/chunker/util.go","lineNumber":31,"sourceCode":"\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/alist-org/alist/v3/internal/errs\"\n\t\"github.com/alist-org/alist/v3/internal/fs\"\n\t\"github.com/alist-org/alist/v3/internal/model\"\n\t\"github.com/alist-org/alist/v3/internal/op\"\n\t\"github.com/alist-org/alist/v3/internal/stream\"\n\t\"github.com/alist-org/alist/v3/pkg/http_range\"\n\t\"github.com/alist-org/alist/v3/pkg/utils\"\n)\n\nfunc (d *Chunker) validateOptions() error {\n\tif strings.TrimSpace(d.RemotePath) == \"\" {\n\t\treturn errors.New(\"remote_path is required\")\n\t}\n\tif d.ChunkSize <= 0 {\n\t\treturn errors.New(\"chunk_size must be positive\")\n\t}\n\tswitch d.MetaFormat {\n\tcase \"simplejson\", \"none\":\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported meta_format: %s\", d.MetaFormat)\n\t}\n\tswitch d.HashType {\n\tcase \"none\", \"md5\", \"sha1\":\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported hash_type: %s\", d.HashType)\n\t}\n\tif d.MetaFormat == \"none\" && d.HashType != \"none\" {\n\t\treturn fmt.Errorf(\"hash_type %q requires meta_format=simplejson\", d.HashType)\n\t}\n\treturn nil\n}\n\nfunc (d *Chunker) configuredRemotePaths() []string {","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/chunker/util.go#L13-L49","documentation":"Returned by Chunker.validateOptions() when chunk_size is zero or negative. Chunk size determines how files are split into remote objects; a non-positive value makes chunk math impossible, so the driver rejects it at init.","triggerScenarios":"Creating a Chunker storage with chunk_size unset (zero default after JSON omission) or manually entering a negative/zero value; older configs where the field did not exist.","commonSituations":"Config written via API/template that omits chunk_size; user assumes an optional field and leaves 0; unit confusion (entering 0 thinking it means 'auto').","solutions":["Set chunk_size to a positive byte count (e.g. 5368709120 for 5 GiB) in the storage addition","Keep the value within what the backing storage supports for a single object","Save and re-open the storage to confirm validation passes"],"exampleFix":"// before\naddition: { remote_path: \"/store\", chunk_size: 0 }\n// after\naddition: { remote_path: \"/store\", chunk_size: 5368709120 }","handlingStrategy":"validation","validationCode":"func validChunkSize(n int64) bool { return n > 0 }\n// e.g. 5 GiB\nif !validChunkSize(addition.ChunkSize) { return errors.New(\"chunk_size must be a positive byte count\") }","typeGuard":"null","tryCatchPattern":"if err := d.validateOptions(); err != nil && strings.Contains(err.Error(), \"chunk_size must be positive\") { /* set chunk_size:5368709120 and re-save */ }","preventionTips":["Always set chunk_size explicitly when creating the storage via API","Default it in templates instead of relying on zero-value","Validate options after every config edit"],"tags":["chunker","config","validation"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}