cayleygraph/cayley · warning

Nothing to log

Error message

Nothing to log

What it means

updateLog returns this when the caller passes an empty delta slice — there are no operations to record in the datastore log. It is a guard against writing an empty LogEntry batch.

Source

Thrown at graph/gaedatastore/quadstore.go:408

		}
		foundMetadata.QuadCount += quadsAdded
		foundMetadata.NodeCount += nodesAdded
		_, err = datastore.Put(c, key, foundMetadata)
		if err != nil {
			clog.Errorf("Error: %v", err)
		}
		return err
	}, nil)
	return err
}

func (qs *QuadStore) updateLog(in []graph.Delta) ([]int64, error) {
	if qs.context == nil {
		err := errors.New("Error updating log, context is nil, graph not correctly initialised")
		return nil, err
	}
	if len(in) == 0 {
		return nil, errors.New("Nothing to log")
	}
	logEntries := make([]LogEntry, 0, len(in))
	logKeys := make([]*datastore.Key, 0, len(in))
	for _, d := range in {
		var action string
		if d.Action == graph.Add {
			action = "Add"
		} else {
			action = "Delete"
		}

		entry := LogEntry{
			Action:    action,
			Key:       qs.createKeyForQuad(d.Quad).String(),
			Timestamp: time.Now().UnixNano(),
		}
		logEntries = append(logEntries, entry)
		logKeys = append(logKeys, qs.createKeyForLog())

View on GitHub (pinned to 81dcd7d73e)

Solutions

  1. Check len(deltas) > 0 before calling ApplyDeltas/updateLog.
  2. Return early in your write path when the batch is empty instead of calling into the store.
  3. If all deltas were intentionally ignored, treat this as a no-op rather than an error in your caller.
  4. Inspect upstream ignoreOpts logic if a non-empty batch shrinks to zero.

Example fix

// before
qs.updateLog(nil)
// after
if len(deltas) == 0 { return nil }
qs.updateLog(deltas)
Defensive patterns

Strategy: validation

Validate before calling

if len(deltas) == 0 {
    return nil // nothing to do
}
return qs.updateLog(deltas)

Try / catch

if err := qs.ApplyDeltas(deltas, ignoreOpts); err != nil {
    if strings.Contains(err.Error(), "Nothing to log") {
        return nil // treat empty batch as no-op
    }
    return err
}

Prevention

When it happens

Trigger: Calling updateLog directly with in == nil or len(in) == 0; ApplyDeltas reaching updateLog with a batch that filtered down to nothing (e.g. all deltas dropped by ignoreOpts handling).

Common situations: Calling ApplyDeltas with an empty slice; batch-assembly code appending no deltas but still invoking the write path; refactoring that split ApplyDeltas and lost the empty-check upstream.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06). Data as JSON: /api/errors/7be5cd877a28a368. Report an issue: GitHub.