cloudreve/cloudreve · warning

invalid range: failed to overlap

Error message

invalid range: failed to overlap

What it means

OneDrive driver Thumb converts a failed GetThumbURL into this wrapped error when OneDrive answers that no thumbnail exists for the file — either the sentinel ErrThumbSizeNotFound or a *RespError with APIError.Code == itemNotFound (onedrive.go:139-150). It marks an expected capability gap, not an outage. Note the fall-through bug: any other error type is silently dropped and the function returns ("", nil), hiding real failures.

Source

Thrown at pkg/filemanager/manager/entitysource/entitysource.go:49

	"github.com/cloudreve/Cloudreve/v4/pkg/setting"
	"github.com/cloudreve/Cloudreve/v4/pkg/util"
	"github.com/juju/ratelimit"
)

const (
	shortSeekBytes = 1024
	// The algorithm uses at most sniffLen bytes to make its decision.
	sniffLen         = 512
	defaultUrlExpire = time.Hour * 1
)

var (
	// ErrNoContentLength is returned by Seek when the initial http response did not include a Content-Length header
	ErrNoContentLength = errors.New("Content-Length was not set")

	// errNoOverlap is returned by serveContent's parseRange if first-byte-pos of
	// all of the byte-range-spec values is greater than the content size.
	errNoOverlap = errors.New("invalid range: failed to overlap")
)

type EntitySource interface {
	io.ReadSeekCloser
	io.ReaderAt

	// Url generates a download url for the entity.
	Url(ctx context.Context, opts ...EntitySourceOption) (*EntityUrl, error)
	// Serve serves the entity to the client, with supports on Range header and If- cache control.
	Serve(w http.ResponseWriter, r *http.Request, opts ...EntitySourceOption)
	// Entity returns the entity of the source.
	Entity() fs.Entity
	// IsLocal returns true if the source is in local machine.
	IsLocal() bool
	// LocalPath returns the local path of the source file.
	LocalPath(ctx context.Context) string
	// Apply applies the options to the source.
	Apply(opts ...EntitySourceOption)

View on GitHub (pinned to 20c95ad73f)

Solutions

  1. Treat as expected: fall back to local thumbnail generation for these files
  2. Restrict the policy's ThumbExts to formats OneDrive handles (jpg/png/pdf and friends)
  3. If nothing gets thumbnails anymore, verify the actual error — the current fall-through swallows non-itemNotFound errors
  4. Cache the negative result so repeated requests don't re-hit Graph

Example fix

// before
res, err := handler.client.GetThumbURL(ctx, e.Source())
if err != nil {
	var apiErr *RespError
	if errors.As(err, &apiErr); err == ErrThumbSizeNotFound || (apiErr != nil && apiErr.APIError.Code == notFoundError) {
		return "", fmt.Errorf("thumb not supported in OneDrive: %w", err)
	}
}
return res, nil

// after — also stop swallowing unexpected errors
res, err := handler.client.GetThumbURL(ctx, e.Source())
if err != nil {
	var apiErr *RespError
	if err == ErrThumbSizeNotFound || (errors.As(err, &apiErr) && apiErr.APIError.Code == notFoundError) {
		return "", fmt.Errorf("thumb not supported in OneDrive: %w", err)
	}
	return "", err
}
return res, nil
Defensive patterns

Strategy: fallback

Validate before calling

// Skip the remote call for extensions OneDrive cannot thumbnail
var odThumbExts = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".pdf": true, ".bmp": true, ".gif": true}
if !odThumbExts[strings.ToLower(path.Ext(e.Source()))] {
	return "", driver.ErrThumbUnsupported // triggers local generation fallback
}

Type guard

func isThumbUnsupported(err error) bool {
	if err == ErrThumbSizeNotFound {
		return true
	}
	var re *RespError
	return errors.As(err, &re) && re.APIError.Code == "itemNotFound"
}

Try / catch

res, err := handler.client.GetThumbURL(ctx, e.Source())
if err != nil {
	if isThumbUnsupported(err) {
		// expected for this file type: fall back to local thumbnail generation
		// or serve a placeholder icon; never fail the file listing
	}
	return "", err // fix the fall-through that currently swallows other errors
}

Prevention

When it happens

Trigger: Requesting thumbnails for file types Graph cannot render (some RAW images, exotic formats, huge videos); files above OneDrive's thumbnail size limits; freshly uploaded content whose thumbnail has not been processed yet.

Common situations: Enabling OneDrive thumbnail proxy for broad extension lists; large media libraries where many files have no server-side preview.

Related errors


AI-assisted analysis of cloudreve/cloudreve@20c95ad73f (2026-08-16). Data as JSON: /api/errors/cd6010300ec68710. Report an issue: GitHub.