dagger/dagger · error

failed to load existing %s: %w

Error message

failed to load existing %s: %w

What it means

When updating dependencies/toolchains, each existing non-local item is re-loaded by re-selecting the 'moduleSource' field with its declared ref string on the dagql server. If that select fails (ref resolution error, network/auth failure for git refs, etc.), the error is wrapped as 'failed to load existing <type>'.

Source

Thrown at core/schema/modulesource.go:1762

	var newUpdatedArgs []core.ModuleSourceID
	for _, existingItem := range accessor.getItems(parentSrc.Self()) {
		if len(updateReqs) == 0 {
			if existingItem.Self().Kind == core.ModuleSourceKindLocal {
				continue
			}

			var updatedItem dagql.ObjectResult[*core.ModuleSource]
			err := dag.Select(updateCtx, dag.Root(), &updatedItem,
				dagql.Selector{
					Field: "moduleSource",
					Args: []dagql.NamedInput{
						{Name: "refString", Value: dagql.String(moduleSourceDeclaredRef(existingItem.Self()))},
					},
				},
			)
			if err != nil {
				return nil, fmt.Errorf("failed to load existing %s: %w", accessor.typ, err)
			}

			updatedItemID, err := updatedItem.ID()
			if err != nil {
				return nil, fmt.Errorf("failed to get updated %s ID: %w", accessor.typ, err)
			}
			newUpdatedArgs = append(newUpdatedArgs, dagql.NewID[*core.ModuleSource](updatedItemID))
			continue
		}

		if existingItem.Self().Kind == core.ModuleSourceKindLocal {
			for updateReq := range updateReqs {
				if updateReq.symbolic == existingItem.Self().ModuleName {
					return nil, fmt.Errorf("updating local %s is not supported", accessor.typ.Plural())
				}

				var contextRoot string
				switch parentSrc.Self().Kind {

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Read the wrapped error; verify the git remote URL is reachable and credentials are available (dagger auth / git config).
  2. Fix the dependency ref in dagger.json if it was hand-edited into an invalid form.
  3. Retry once network is restored — resolution errors are often transient.
  4. Run 'dagger develop' to re-resolve all deps and see which ref fails.

Example fix

// before: unreachable ref
.withDependency(gitRef("github.com/myorg/removed-repo"))
// after: fix to the moved location
.withDependency(gitRef("github.com/myorg/renamed-repo"))
Defensive patterns

Strategy: retry

Validate before calling

// Go: pre-check that each git dep remote is reachable before updating
for _, dep := range gitDeps {
    if err := checkRemoteReachable(dep.CloneRef); err != nil {
        return fmt.Errorf("dep %s remote unreachable: %w", dep.ModuleName, err)
    }
}

Try / catch

err := mod.UpdateDependencies(ctx, nil) // update all
if err != nil && strings.Contains(err.Error(), "failed to load existing") {
    if isTransient(err) { // network timeouts
        time.Sleep(2 * time.Second)
        err = mod.UpdateDependencies(ctx, nil)
    }
}

Prevention

When it happens

Trigger: updateDependencies()/updateToolchains() where moduleSourceDeclaredRef(existingItem) cannot be re-resolved: unreachable or renamed git remote, invalid ref string, auth failure on private repos, or dagql select error.

Common situations: Git dependency remote deleted/moved or renamed branch; private repo credentials missing in the session; network outage during 'dagger develop/update'; dependency ref string malformed after manual dagger.json edits.

Related errors


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