dagger/dagger · error

failed to get current module: %w

Error message

failed to get current module: %w

What it means

After obtaining the query, the CachePerCallerModule resolver calls q.CurrentModule(ctx) to scope the cache key by the caller module's source digest. Any error other than ErrNoCurrentModule is wrapped with this message, meaning module lookup failed unexpectedly and a cache scope cannot be derived (an empty string input is returned to signal failure).

Source

Thrown at core/client_resource.go:53

	h := hmac.New(digest.SHA256.Hash, []byte(scopeDigest))
	dt := h.Sum([]byte(externalName))
	return hex.EncodeToString(dt), nil
}

// CachePerCallerModule scopes a call ID per caller module (using the module's source content digest). If the caller is not in a module, the input is just an empty string.
var CachePerCallerModule = dagql.ImplicitInput{
	Name: "cachePerCallerModule",
	Resolver: func(ctx context.Context, _ map[string]dagql.Input) (dagql.Input, error) {
		q, err := CurrentQuery(ctx)
		if err != nil {
			return nil, fmt.Errorf("current query: %w", err)
		}
		m, err := q.CurrentModule(ctx)
		if errors.Is(err, ErrNoCurrentModule) {
			return dagql.NewString("mainClient"), nil
		}
		if err != nil {
			return dagql.NewString(""), fmt.Errorf("failed to get current module: %w", err)
		}
		if m.Self() == nil {
			return dagql.NewString("mainClient"), nil
		}

		scopedMod, err := ImplementationScopedModule(ctx, m)
		if err != nil {
			return nil, err
		}
		scopeDigest, err := scopedMod.ContentPreferredDigest(ctx)
		if err != nil {
			return nil, err
		}

		return dagql.NewString(scopeDigest.String()), nil
	},
}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Check the wrapped inner error to find the CurrentModule failure cause
  2. Ensure the function is called after module initialization completes in the session lifecycle
  3. If the caller legitimately has no module, rely on ErrNoCurrentModule handling — this error indicates a real failure, not a missing module
  4. Retry the operation if the failure was transient (e.g. during session teardown races)
Defensive patterns

Strategy: try-catch

Try / catch

input, err := resolver(ctx, nil)
if err != nil {
    if !errors.Is(err, core.ErrNoCurrentModule) && strings.Contains(err.Error(), "failed to get current module") {
        log.Printf("module lookup failed: %v", err)
    }
}

Prevention

When it happens

Trigger: q.CurrentModule(ctx) returns a non-ErrNoCurrentModule error while resolving the cachePerCallerModule implicit input — e.g. internal module state is inconsistent, or module introspection hit a backend failure.

Common situations: Calling a cached function during module loading before the module registry is ready; corrupted module metadata in the session; errors surfacing from CurrentModule's own dependency lookups.

Related errors


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