dagger/dagger · error

evaluate structural diff: %w

Error message

evaluate structural diff: %w

What it means

This error wraps failure of cache.Evaluate on the diff directory result. Computing the diff via srv.Select only queues the lazy dagql call; Evaluate forces it to run. Failure here means the diff directory's underlying evaluation (snapshot construction) errored or the context was canceled.

Source

Thrown at core/directory.go:3095

	}

	var diffDir dagql.ObjectResult[*Directory]
	afterID, err := changes.Self().After.ID()
	if err != nil {
		return fmt.Errorf("after ID: %w", err)
	}
	if err := srv.Select(ctx, changes.Self().Before, &diffDir,
		dagql.Selector{
			Field: "diff",
			Args: []dagql.NamedInput{
				{Name: "other", Value: dagql.NewID[*Directory](afterID)},
			},
		},
	); err != nil {
		return fmt.Errorf("compute structural diff: %w", err)
	}
	if err := cache.Evaluate(ctx, diffDir); err != nil {
		return fmt.Errorf("evaluate structural diff: %w", err)
	}

	var diffSnapshot bkcache.ImmutableRef
	diffPath := "/"
	if diffDir.Self() != nil {
		diffSnapshot, err = diffDir.Self().Snapshot.GetOrEval(ctx, diffDir.Result)
		if err != nil {
			return fmt.Errorf("diff snapshot: %w", err)
		}
		diffPath, err = diffDir.Self().Dir.GetOrEval(ctx, diffDir.Result)
		if err != nil {
			return fmt.Errorf("diff path: %w", err)
		}
		if diffPath == "" {
			diffPath = "/"
		}
	}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Read the wrapped cause; 'context canceled' means the client disconnected — rerun the operation.
  2. Free engine disk / prune cache if evaluation failed from ENOSPC, then retry.
  3. Verify engine and CLI versions match; mismatched builds can fail evaluation of lazily-created objects.
  4. Retry the pipeline; if reproducible, capture engine logs and report with the inner error.

Example fix

// before
if err := cache.Evaluate(ctx, diffDir); err != nil {
	return fmt.Errorf("evaluate structural diff: %w", err)
}
// after
if err := cache.Evaluate(ctx, diffDir); err != nil {
	return fmt.Errorf("evaluate structural diff: %w", err) // check inner cause: canceled vs IO vs cache
}
Defensive patterns

Strategy: retry

Validate before calling

if ctx.Err() != nil { return errors.New("context canceled before diff evaluation") }
// verify sufficient engine disk before large diffs

Try / catch

for attempt := 0; attempt < 2; attempt++ { if err := evalDiff(); err == nil { break }; if !isTransient(err) { return err } }

Prevention

When it happens

Trigger: Applying a Directory changeset where evaluating the intermediate Before.diff(other) result fails — e.g. blob mounts unavailable, disk full, engine cache ref lost mid-evaluation, or client disconnects canceling the context.

Common situations: Engine under disk pressure while materializing diff layers; session cancellation; flaky underlying storage in remote cache setups.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/977e2d145368f8be. Report an issue: GitHub.