AlistGo/alist · warning · ErrBaiduEmptyFilesNotAllowed

empty files are not allowed by baidu netdisk

Error message

empty files are not allowed by baidu netdisk

What it means

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.

Source

Thrown at drivers/baidu_netdisk/types.go:14

package baidu_netdisk

import (
	"errors"
	"path"
	"strconv"
	"time"

	"github.com/alist-org/alist/v3/internal/model"
	"github.com/alist-org/alist/v3/pkg/utils"
)

var (
	ErrBaiduEmptyFilesNotAllowed = errors.New("empty files are not allowed by baidu netdisk")
)

type TokenErrResp struct {
	ErrorDescription string `json:"error_description"`
	Error            string `json:"error"`
}

type File struct {
	//TkbindId     int    `json:"tkbind_id"`
	//OwnerType    int    `json:"owner_type"`
	Category int `json:"category"`
	//RealCategory string `json:"real_category"`
	FsId int64 `json:"fs_id"`
	//OperId      int   `json:"oper_id"`
	Thumbs struct {
		//Icon string `json:"icon"`
		Url3 string `json:"url3"`
		//Url2 string `json:"url2"`

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Filter out zero-byte files before uploading to Baidu Netdisk (skip them in your sync/copy job)
  2. If the empty file matters, upload a 1-byte placeholder instead and strip it on restore
  3. Treat this error as non-fatal in batch jobs: log and continue

Example fix

// before
for _, f := range files { put(f) }
// after
for _, f := range files {
    if f.Size() == 0 { continue } // baidu rejects empty files
    put(f)
}
Defensive patterns

Strategy: validation

Validate before calling

if stream.GetSize() == 0 {
    return nil // or errors.Is(err, ErrBaiduEmptyFilesNotAllowed) path: skip
}

Try / catch

err := d.Put(ctx, dst, stream, up)
if err != nil && errors.Is(err, errs.ErrBaiduEmptyFilesNotAllowed) { return nil /* skip empty files */ }

Prevention

When it happens

Trigger: 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.

Common situations: Syncing directory trees that contain placeholder files (.gitkeep, empty logs); copying tools that touch empty files first; automated backups generating zero-byte markers.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/39b874f0a22dc5e7. Report an issue: GitHub.