dagger/dagger · error

failed to create method %s for %s: %w

Error message

failed to create method %s for %s: %w

What it means

Wraps a failure from createFunction while converting a public function-typed slot of a Dang class into a core.Function definition inside createObjectTypeDef. Fires when method creation fails (unresolvable types, schema select errors), aborting the whole class TypeDef and initDangModule.

Source

Thrown at core/sdk/dang/v1/helpers.go:718

		if !ok || slot.Visibility < dang.PublicVisibility {
			continue
		}

		bindingName := slot.Name.Name
		scheme, found := classMod.LocalSchemeOf(bindingName)
		if !found {
			return res, fmt.Errorf("missing local slot %s for %s", bindingName, name)
		}

		slotType, isMono := scheme.Type()
		if !isMono {
			return res, fmt.Errorf("non-monotype method %s", bindingName)
		}
		switch x := slotType.(type) {
		case *hm.FunctionType:
			fnDef, err := createFunction(ctx, srv, classMod, bindingName, x, module.Closure, localTypes)
			if err != nil {
				return res, fmt.Errorf("failed to create method %s for %s: %w", bindingName, name, err)
			}
			fnDefID, err := fnDef.ID()
			if err != nil {
				return res, fmt.Errorf("failed to get function ID for %s: %w", bindingName, err)
			}

			sels = append(sels, dagql.Selector{
				Field: "withFunction",
				Args:  []dagql.NamedInput{{Name: "function", Value: dagql.NewID[*core.Function](fnDefID)}},
			})
		default:
			fieldDef, err := dangTypeToTypeDef(ctx, srv, slotType, localTypes)
			if err != nil {
				return res, fmt.Errorf("failed to create field %s: %w", bindingName, err)
			}
			fieldDefID, err := fieldDef.ID()
			if err != nil {
				return res, fmt.Errorf("failed to get field type ID for %s: %w", bindingName, err)

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Inspect the wrapped cause for the real failure inside createFunction.
  2. Verify the class method uses resolvable monomorphic types and the Dang module compiles.
  3. Fix the offending method or mark the slot private so it is skipped from binding generation.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at core/sdk/dang/v1/helpers.go:718 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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