dagger/dagger · error

context directory ID: %w

Error message

context directory ID: %w

What it means

Wraps a failure to compute the dagql ID of the Directory instance produced while loading a module source's context directory. The ID is needed to fingerprint the directory call for content-digest caching; if ID derivation fails (invalid/corrupt result, unset dagql instance), this error is returned.

Source

Thrown at core/modulesource.go:1516

	//
	//   1. a Workspace explicitly bound into the context (an LLM bound via
	//      withWorkspace), so the agent's defaultPath args resolve against its
	//      own (possibly overlaid) workspace;
	//   2. otherwise the module source itself.
	//
	// NOTE: this applies unilaterally, whether the module was loaded from Host,
	// Git, or a Directory.
	if ws, ok := WorkspaceFromContext(ctx); ok {
		inst, err = src.loadContextFromWorkspace(ctx, dag, ws, path, filterInputs)
	} else {
		inst, err = NewModuleSourceFS(nil, src).directory(ctx, dag, path, filterInputs)
	}
	if err != nil {
		return inst, err
	}
	instID, err := inst.ID()
	if err != nil {
		return inst, fmt.Errorf("context directory ID: %w", err)
	}
	instCall, err := inst.ResultCall()
	if err != nil {
		return inst, fmt.Errorf("context directory call: %w", err)
	}
	if instID != nil && instCall.ContentDigest() == "" {
		snapshot, err := inst.Self().Snapshot.GetOrEval(ctx, inst.Result)
		if err != nil {
			return inst, fmt.Errorf("context directory snapshot: %w", err)
		}
		dirPath, err := inst.Self().Dir.GetOrEval(ctx, inst.Result)
		if err != nil {
			return inst, fmt.Errorf("context directory path: %w", err)
		}
		dgst, err := GetContentHashFromDirectory(ctx, snapshot, dirPath)
		if err != nil {
			return inst, fmt.Errorf("failed to content-hash contextual directory: %w", err)
		}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Inspect the wrapped inner error for the actual ID-encoding failure
  2. Re-run the operation; transient evaluation failures can corrupt the instance
  3. Verify the directory was produced by a valid dagql Select (not manually constructed)
  4. Report upstream with the wrapped error if reproducible in a stock Dagger flow

Example fix

// before: constructing a Directory outside dagql and passing it through context-dir loading
inst := dagql.NewInstanceForCurrentOperation(false, dir)
// after: obtain the directory through the dagql server so ID() succeeds
dag.Select(ctx, dag.Root(), &inst, dagql.Selector{Field: "directory", ...})
Defensive patterns

Strategy: try-catch

Validate before calling

// Go: verify the directory instance came from a dagql Select before ID()
if inst.Self() == nil {
    return fmt.Errorf("directory instance uninitialized")
}

Type guard

func hasID(inst dagql.ObjectResult[*core.Directory]) bool {
    _, err := inst.ID()
    return err == nil
}

Try / catch

instID, err := inst.ID()
if err != nil {
    return nil, fmt.Errorf("context directory ID: %w", err)
}

Prevention

When it happens

Trigger: ModuleSource.LoadContextDir is called and the returned Directory dagql instance cannot produce an ID — e.g. the instance result was never properly evaluated or the dagql ID encoding fails.

Common situations: Seen during module function execution when resolving contextual (+defaultPath) directories; typically indicates an internal dagql state bug or a corrupted/unsaved Directory instance rather than user error.

Related errors


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