dagger/dagger · error
attach module self dependency %q: dep ID: %w
Error message
attach module self dependency %q: dep ID: %w
What it means
While attaching dependency results, each dependency module's dagql ID is fetched to compare its EngineResultID with the attached self module's. This error wraps the failure to get the ID of a dependency module instance, reported with the dependency module's name (%q).
Source
Thrown at core/module.go:983
return nil, fmt.Errorf("attach module self dependency: missing module deps")
}
attachedSelf, ok := self.(dagql.ObjectResult[*Module])
if !ok {
return nil, fmt.Errorf("attach module self dependency: expected attached module result, got %T", self)
}
attachedSelfID, err := attachedSelf.ID()
if err != nil {
return nil, fmt.Errorf("attach module self dependency: self ID: %w", err)
}
seenSelf := false
for i, dep := range mod.Deps.entries {
depInst := dep.mod.ModuleResult()
if depInst.Self() == nil {
continue
}
depID, err := depInst.ID()
if err != nil {
return nil, fmt.Errorf("attach module self dependency %q: dep ID: %w", dep.mod.Name(), err)
}
if depID == nil || depID.EngineResultID() != attachedSelfID.EngineResultID() {
continue
}
mod.Deps.entries[i].mod = NewUserMod(attachedSelf)
seenSelf = true
break
}
if !seenSelf {
mod.Deps = mod.Deps.Append(NewUserMod(attachedSelf))
}
}
return owned, nil
}
type persistedModulePayload struct {
SourceResultID uint64 `json:"sourceResultID,omitempty"`
ContextSourceResultID uint64 `json:"contextSourceResultID,omitempty"`View on GitHub (pinned to 82ba2681db)
Solutions
- Read the wrapped error and the dependency name in the message to identify the broken dep
- Re-resolve the dependency module through the live dagql session instead of caching ModuleResult
- Re-run the module installation (dagger mod use) to refresh dependency instances
- Check that the dependency's Self() result is attached to the same server as self
Example fix
// before
var cachedDep *Module // stale, ID() fails
// after
depRes, err := dagql.NewModule(dag, depSource).Evaluate(ctx) // fresh result
if err != nil { return err } Defensive patterns
Strategy: try-catch
Validate before calling
for _, dep := range mod.Deps.entries {
if inst := dep.mod.ModuleResult(); inst.Self() != nil {
if _, err := inst.ID(); err != nil { return fmt.Errorf("dep %q unresolvable: %w", dep.mod.Name(), err) }
}
} Type guard
func depResolvable(dep *ModuleDep) bool { inst := dep.mod.ModuleResult(); return inst == nil || inst.Self() == nil || validID(inst) } Try / catch
res, err := mod.AttachDependencyResults(ctx, self)
if err != nil {
var name string
if m := depNameRe.FindStringSubmatch(err.Error()); m != nil { name = m[1] }
return fmt.Errorf("re-install dependency %q: %w", name, err)
} Prevention
- Re-resolve dependency ModuleResults from the current session before attaching
- Re-run dagger mod use after dependency changes
- Avoid mixing results from multiple dagql servers
When it happens
Trigger: AttachDependencyResults iterates mod.Deps and calls depInst.ID() on a dependency module whose Self() is non-nil; that ID() call fails, e.g. because the dependency's ModuleResult is not properly registered with the dagql server.
Common situations: A module declares a dependency on another local module whose instance was constructed outside the current dagql session; stale or broken module caches after engine restarts.
Related errors
- attach module self dependency: self ID: %w
- load handle type: %w
- result call: %w
- module provenance: module %q handle ID: %w
- load object ID: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/f64ba33045436f3a.
Report an issue: GitHub.