juicedata/juicefs · error

not exists

Error message

not exists

What it means

mem.go's in-memory object store returns "not exists" from Get when the requested key is absent from its objects map. It is the mem-store analogue of an object-storage 404/NoSuchKey. Callers like Copy use it to detect a missing source object.

Source

Thrown at pkg/object/mem.go:87

		},
		o.owner,
		o.group,
		o.mode,
		false,
	}
	return f, nil
}

func (m *memStore) Get(ctx context.Context, key string, off, limit int64, getters ...AttrGetter) (io.ReadCloser, error) {
	m.Lock()
	defer m.Unlock()
	// Minimum length is 1.
	if key == "" {
		return nil, errors.New("object key cannot be empty")
	}
	d, ok := m.objects[key]
	if !ok {
		return nil, errors.New("not exists")
	}
	if off > int64(len(d.data)) {
		off = int64(len(d.data))
	}
	data := d.data[off:]
	if limit > 0 && limit < int64(len(data)) {
		data = data[:limit]
	}
	return io.NopCloser(bytes.NewBuffer(data)), nil
}

func (m *memStore) Put(ctx context.Context, key string, in io.Reader, getters ...AttrGetter) error {
	m.Lock()
	defer m.Unlock()
	// Minimum length is 1.
	if key == "" {
		return errors.New("object key cannot be empty")
	}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Head the key first (or check the map) before Get, or handle the not-found error explicitly
  2. Verify the exact key string including case, prefix, and trailing '/'
  3. Re-put the object before reading if it was expected to exist

Example fix

// before
obj, err := store.Get(ctx, key, 0, -1)
// after
obj, err := store.Get(ctx, key, 0, -1)
if err != nil && strings.Contains(err.Error(), "not exists") {
	logger.Warnf("object %s missing, skipping", key)
	return nil
}
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := store.Head(ctx, key); err != nil {
	// key absent; skip or create
}

Type guard

func isNotFound(err error) bool { return err != nil && strings.Contains(err.Error(), "not exists") }

Try / catch

obj, err := store.Get(ctx, key, 0, -1)
if err != nil {
	if isNotFound(err) { return nil } // handle missing
	return err
}

Prevention

When it happens

Trigger: Calling Get on a memStore with a key that was never Put, was Deleted, or whose name differs in case/spelling; Copy reading from a source key that no longer exists.

Common situations: Unit tests using mem as a fake store where the fixture object was never seeded; sync/copy jobs where the source key was concurrently deleted; typos or trailing-slash mismatches in keys.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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