Skip to content

🐞 Populated nullable object fields fail to convert when a module object is passed as a function argument #13400

Closed

Description

@sagikazarmark

What is the issue?

When a module object with a nullable object-reference field (File, Secret) is passed back into a module function as an argument, the call fails if the field holds a non-null value:

Error: set call inputs: convert arg "foo": convert field "file": *core.NullableType.ConvertToSDKInput: expected Derefable, got dagql.Result[*github.com/dagger/dagger/core.File]: dagql.Result[*github.com/dagger/dagger/core.File]{shared:(*dagql.sharedResult)(0x...), hitCache:true, derefView:false, nullableWrapped:true}

What works and what doesn't:

Case Result
nullable File/Secret field, value is null ✅ works
nullable scalar field (String, Boolean), value populated ✅ works
nullable File/Secret field populated, object returned from a function (output direction, including calling functions on the returned object) ✅ works
nullable File/Secret field populated, object passed as a function argument ❌ fails

So only the call-input conversion path is affected. The error comes from ConvertToSDKInput in core/modtypes.go, which expects a dagql.Derefable but receives the value wrapped in a dagql.Result (nullableWrapped:true).

The workaround is to declare such fields non-null and use sentinel values (e.g. an empty Secret) — but that loses the ability to model genuinely optional fields on objects that are meant to be passed back into module functions (e.g. an issuer/CA object with an optional key password).

Encountered with the dang SDK, but the failing conversion is engine-side, so other SDKs may be affected as well.

Dagger version

dagger v1.0.0-beta.3 (image://registry.dagger.io/engine:v1.0.0-beta.3) darwin/arm64/v8

Steps to reproduce

Two dang modules: foobar, and foobar/tests depending on it. The test functions obtain a Foo from the dependency and immediately pass it back as an argument.

foobar/dagger-module.toml:

name = "foobar"
engineVersion = "v1.0.0-beta.3"
runtime.source = "dang"
include = ["!tests"]

foobar/main.dang:

type Foo {
  pub file: File
  pub secret: Secret
  pub note: String
}

type Foobar {
  pub make(
    file: File = null,
    secret: Secret = null,
    note: String = null,
  ): Foo! {
    Foo(file, secret, note)
  }

  pub use(foo: Foo!): String! {
    "ok"
  }
}

foobar/tests/dagger-module.toml:

name = "tests"
engineVersion = "v1.0.0-beta.3"
runtime.source = "dang"

[[dependencies]]
name = "foobar"
source = ".."

foobar/tests/main.dang:

type Tests {
  pub allNull: String! {
    Dagger.foobar.use(Dagger.foobar.make)
  }

  pub filePopulated: String! {
    Dagger.foobar.use(Dagger.foobar.make(file: Dagger.file("foo.txt", "bar")))
  }

  pub secretPopulated: String! {
    Dagger.foobar.use(Dagger.foobar.make(secret: Dagger.setSecret("foo", "bar")))
  }

  pub stringPopulated: String! {
    Dagger.foobar.use(Dagger.foobar.make(note: "foo"))
  }
}

Run:

dagger call -m foobar/tests all-null          # ✅ ok
dagger call -m foobar/tests string-populated  # ✅ ok
dagger call -m foobar/tests file-populated    # ❌ fails
dagger call -m foobar/tests secret-populated  # ❌ fails

Log output

$ dagger call -m foobar/tests file-populated
Error: set call inputs: convert arg "foo": convert field "file": *core.NullableType.ConvertToSDKInput: expected Derefable, got dagql.Result[*github.com/dagger/dagger/core.File]: dagql.Result[*github.com/dagger/dagger/core.File]{shared:(*dagql.sharedResult)(0x4bc592c99380), hitCache:true, derefView:false, nullableWrapped:true}

$ dagger call -m foobar/tests secret-populated
Error: set call inputs: convert arg "foo": convert field "secret": *core.NullableType.ConvertToSDKInput: expected Derefable, got dagql.Result[*github.com/dagger/dagger/core.Secret]: dagql.Result[*github.com/dagger/dagger/core.Secret]{shared:(*dagql.sharedResult)(0x4bc620041a00), hitCache:true, derefView:false, nullableWrapped:true}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions