dagger/dagger · error

%T.ConvertToSDKInput: unknown type %T

Error message

%T.ConvertToSDKInput: unknown type %T

What it means

ConvertToSDKInput converts a dagql value into a plain SDK input (usually an encoded ID string). If the value is neither a dagql.Input nor a dagql.AnyResult, the type is unknown to this CoreModObject and the error "%T.ConvertToSDKInput: unknown type %T" is returned. This is an internal type-contract violation for core object types.

Source

Thrown at core/schema/coremod.go:828

func (obj *CoreModObject) ConvertToSDKInput(ctx context.Context, value dagql.Typed) (any, error) {
	if value == nil {
		return nil, nil
	}
	switch x := value.(type) {
	case dagql.Input:
		return x, nil
	case dagql.AnyResult:
		id, err := x.ID()
		if err != nil {
			return nil, err
		}
		if id == nil {
			return nil, nil
		}
		return id.Encode()
	default:
		return nil, fmt.Errorf("%T.ConvertToSDKInput: unknown type %T", obj, value)
	}
}

func (obj *CoreModObject) CollectContent(ctx context.Context, value dagql.AnyResult, content *core.CollectedContent) error {
	if value == nil {
		if err := content.CollectJSONable(nil); err != nil {
			return fmt.Errorf("collect_jsonable nil core object %q: %w", obj.name, err)
		}
		return nil
	}
	switch x := value.(type) {
	case dagql.Input:
		if err := content.CollectJSONable(x); err != nil {
			return fmt.Errorf("collect_jsonable input core object %q (%T): %w", obj.name, x, err)
		}
		return nil
	case dagql.AnyResult:
		id, err := x.ID()

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Wrap the value as a dagql result/input before conversion — pass the dagql.AnyResult obtained from a query select.
  2. If you control the code, add a case for the new dagql.Typed type in the switch in ConvertToSDKInput.
  3. Check the %T in the message to identify which concrete type leaked in and fix where it was produced.
  4. Upgrade Dagger so the conversion layer supports the type introduced by your SDK version.

Example fix

// before
in, err := obj.ConvertToSDKInput(ctx, myPlainContainerStruct)

// after
res := dagql.NewResultForCurrentCall(ctx, ctrTyped) // dagql.AnyResult
in, err := obj.ConvertToSDKInput(ctx, res)
Defensive patterns

Strategy: type-guard

Type guard

func isConvertibleSDKInput(v dagql.Typed) bool {
	switch v.(type) {
	case dagql.Input, dagql.AnyResult, nil:
		return true
	default:
		return false
	}
}

Try / catch

in, err := obj.ConvertToSDKInput(ctx, value)
if err != nil {
	if strings.Contains(err.Error(), "unknown type") {
		return fmt.Errorf("value of type %T must be a dagql Input or AnyResult", value)
	}
	return err
}

Prevention

When it happens

Trigger: Passing a value that is neither a dagql.Input nor dagql.AnyResult (e.g. a raw struct, string, or wrong Typed wrapper) into ConvertToSDKInput for a core object type like Container or Directory.

Common situations: Custom SDK generators or module tooling feeding mis-typed values through the mod-type conversion layer; forked Dagger code passing wrong wrappers; schema changes introducing new Typed kinds not handled by the switch.

Related errors


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