juicedata/juicefs · error

errDirSuffix

errDirSuffix

Error message

dir miss suffix '/'

What it means

errDirSuffix is returned by produceSingleObject (used by --files-from) when the input names a directory-like key that lacks a trailing '/'. Sync requires directory keys to end with '/' so it can treat them as directories rather than files.

Source

Thrown at pkg/sync/sync.go:1924

	for scanner.Scan() {
		key := scanner.Text()
		if key == "" {
			continue
		}
		trimKey := strings.TrimRightFunc(key, unicode.IsSpace)
		if trimKey != key {
			logger.Infof("found a prefix with a space character:%q", key)
		}
		prefixs <- trimKey
	}
	close(prefixs)

	wg.Wait()
	listedPrefix.Done()
	return nil
}

var errDirSuffix = errors.New("dir miss suffix '/'")
var ignoreFiles int64

func produceSingleObject(tasks chan<- object.Object, src, dst object.ObjectStorage, key string, config *Config, checkpointMgr *CheckpointManager) error {
	obj, err := src.Head(ctx, key)
	if err != nil {
		if config.Links && (errors.Is(err, utils.ErrExtlink) || errors.Is(err, syscall.ENOTSUP) || errors.Is(err, os.ErrNotExist)) {
			if sl, ok := src.(object.SupportSymlink); ok {
				if target, e := sl.Readlink(key); e == nil {
					obj, err = object.NewSymlink(key, target), nil
				} else {
					err = fmt.Errorf("readlink %s from %s: %w", key, src, e)
				}
			}
		}
		if err != nil {
			logger.Warnf("head %s from %s: %s", key, src, err)
			return err
		}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Append '/' to directory entries in the --files-from list
  2. Or pass the key through Head first: the sync code itself appends '/' when it sees errDirSuffix — normalize your list the same way
  3. Exclude directories from the list if you only intend to sync files

Example fix

# before
subdir
# after
subdir/
Defensive patterns

Strategy: validation

Validate before calling

if isDir && !strings.HasSuffix(key, "/") {
	key += "/" // normalize directory keys before --files-from
}

Prevention

When it happens

Trigger: Running juicefs sync with --files-from where a line lists a directory without a trailing slash; keys computed from user lists that omit the suffix.

Common situations: Generating the files-from list with find/ls without appending '/' to directories; copying lists between systems with different directory conventions.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/6940078123d735e7. Report an issue: GitHub.