dagger/dagger · error
apply changes to workspace root: %w
Error message
apply changes to workspace root: %w
What it means
This error wraps a failure of the dagql Select call that applies a changeset to the workspace root directory via Directory.withChanges, inside generatedWorkspaceRoot. The root is read as a full Directory (not the sparse workspace overlay) and each run changeset is chained on; if the select/query fails (invalid changeset, directory read error, engine error), the workspace-root generation aborts.
Source
Thrown at core/generators.go:345
return dagql.ObjectResult[*Directory]{}, err
}
var root dagql.ObjectResult[*Directory]
if err := dag.Select(ctx, gg.BoundWorkspace, &root, dagql.Selector{
Field: "directory",
Args: []dagql.NamedInput{{Name: "path", Value: dagql.NewString("/")}},
}); err != nil {
return dagql.ObjectResult[*Directory]{}, fmt.Errorf("read workspace root: %w", err)
}
for _, cs := range changes {
csID, err := cs.ID()
if err != nil {
return dagql.ObjectResult[*Directory]{}, fmt.Errorf("changeset ID: %w", err)
}
if err := dag.Select(ctx, root, &root, dagql.Selector{
Field: "withChanges",
Args: []dagql.NamedInput{{Name: "changes", Value: dagql.NewID[*Changeset](csID)}},
}); err != nil {
return dagql.ObjectResult[*Directory]{}, fmt.Errorf("apply changes to workspace root: %w", err)
}
}
return root, nil
}
// verifySkippedModule loads one skipped module from the generated workspace
// root and records the outcome on its "regenerated" span: OK, or the described
// post-generation load error. The span's status is the whole answer; the
// report words a success itself (idtui regeneratedModuleMessage).
func verifySkippedModule(ctx context.Context, generated dagql.ObjectResult[*Directory], failure ModuleLoadFailure) {
var rerr error
ctx, span := Tracer(ctx).Start(ctx, failure.Name,
telemetry.Reveal(),
trace.WithAttributes(
attribute.Bool(telemetryattrs.GenerateRegeneratedAttr, true),
attribute.Bool(telemetry.UIRollUpLogsAttr, true),
attribute.Bool(telemetry.UIRollUpSpansAttr, true),
),View on GitHub (pinned to 82ba2681db)
Solutions
- Inspect the wrapped cause (%w) — it names the actual withChanges failure
- Re-run with a healthy engine cache; clear or GC corrupted engine cache state if blobs are unreadable
- Ensure CLI and engine versions match (dagger engine upgrade / CLI upgrade in lockstep)
- If a specific module's changeset triggers it, regenerate that module in isolation to identify the offending changes
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the base directory resolves before applying changes:
var probe dagql.ObjectResult[*Directory]
if err := dag.Select(ctx, gg.BoundWorkspace, &probe, dagql.Selector{
Field: "directory",
Args: []dagql.NamedInput{{Name: "path", Value: dagql.NewString("/")}},
}); err != nil {
return fmt.Errorf("workspace root unreadable: %w", err)
} Try / catch
if err := dag.Select(ctx, root, &root, dagql.Selector{Field: "withChanges", Args: ...}); err != nil {
if errors.Is(err, context.DeadlineExceeded) {
// retry with a larger timeout
}
return fmt.Errorf("apply changes to workspace root: %w", err)
} Prevention
- Keep engine cache storage healthy and sized for the workspace
- Match CLI/engine versions to avoid withChanges schema skew
- Regenerate failed modules individually to isolate a bad changeset
- Avoid killing the engine mid-write of changeset blobs
When it happens
Trigger: generatedWorkspaceRoot iterating over run changesets when dag.Select(ctx, root, &root, {Field: "withChanges"}) returns an error — e.g. the changeset ID is invalid, the base directory failed to materialize, or the engine errored evaluating withChanges.
Common situations: Engine storage/cache corruption preventing the base directory or changeset blobs from being read; a changeset produced by a failed/aborted generator step; very large changesets failing during evaluation; version mismatch between CLI and engine causing field/argument incompatibilities.
Related errors
- encode persisted generated code: missing code directory
- attach generated code directory: unexpected result %T
- compute structural diff: %w
- read workspace root: %w
- namespace interface function id: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/e049a2f8e35e9152.
Report an issue: GitHub.