{"record":{"id":"39b874f0a22dc5e7","repo":"AlistGo/alist","slug":"empty-files-are-not-allowed-by-baidu-netdisk","errorCode":null,"errorMessage":"empty files are not allowed by baidu netdisk","messagePattern":"empty files are not allowed by baidu netdisk","errorType":"exception","errorClass":"ErrBaiduEmptyFilesNotAllowed","httpStatus":null,"severity":"warning","filePath":"drivers/baidu_netdisk/types.go","lineNumber":14,"sourceCode":"package baidu_netdisk\n\nimport (\n\t\"errors\"\n\t\"path\"\n\t\"strconv\"\n\t\"time\"\n\n\t\"github.com/alist-org/alist/v3/internal/model\"\n\t\"github.com/alist-org/alist/v3/pkg/utils\"\n)\n\nvar (\n\tErrBaiduEmptyFilesNotAllowed = errors.New(\"empty files are not allowed by baidu netdisk\")\n)\n\ntype TokenErrResp struct {\n\tErrorDescription string `json:\"error_description\"`\n\tError            string `json:\"error\"`\n}\n\ntype File struct {\n\t//TkbindId     int    `json:\"tkbind_id\"`\n\t//OwnerType    int    `json:\"owner_type\"`\n\tCategory int `json:\"category\"`\n\t//RealCategory string `json:\"real_category\"`\n\tFsId int64 `json:\"fs_id\"`\n\t//OperId      int   `json:\"oper_id\"`\n\tThumbs struct {\n\t\t//Icon string `json:\"icon\"`\n\t\tUrl3 string `json:\"url3\"`\n\t\t//Url2 string `json:\"url2\"`","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/baidu_netdisk/types.go#L1-L32","documentation":"Sentinel error ErrBaiduEmptyFilesNotAllowed declared in drivers/baidu_netdisk/types.go. Baidu Netdisk's API rejects creation of zero-byte files, so the driver raises this before/after attempting an empty upload to give a clear reason.","triggerScenarios":"Calling Put() with a stream whose size is 0 (empty file) against a Baidu Netdisk storage; the pre-create/upload API would fail server-side.","commonSituations":"Syncing directory trees that contain placeholder files (.gitkeep, empty logs); copying tools that touch empty files first; automated backups generating zero-byte markers.","solutions":["Filter out zero-byte files before uploading to Baidu Netdisk (skip them in your sync/copy job)","If the empty file matters, upload a 1-byte placeholder instead and strip it on restore","Treat this error as non-fatal in batch jobs: log and continue"],"exampleFix":"// before\nfor _, f := range files { put(f) }\n// after\nfor _, f := range files {\n    if f.Size() == 0 { continue } // baidu rejects empty files\n    put(f)\n}","handlingStrategy":"validation","validationCode":"if stream.GetSize() == 0 {\n    return nil // or errors.Is(err, ErrBaiduEmptyFilesNotAllowed) path: skip\n}","typeGuard":null,"tryCatchPattern":"err := d.Put(ctx, dst, stream, up)\nif err != nil && errors.Is(err, errs.ErrBaiduEmptyFilesNotAllowed) { return nil /* skip empty files */ }","preventionTips":["Filter zero-byte files in sync jobs targeting Baidu Netdisk","Use errors.Is against the exported sentinel","Log skips instead of failing the batch"],"tags":["baidu-netdisk","upload","empty-file"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}