Skip to content

Kill +defaultPath in favor of just +default #11745

Closed

Description

@kpenfound

This is a discussion to decide if we should get rid of defaultPath and defaultAddress to just use default for everything. We should discuss context for why things are the way they are, blockers for making the change, and how the change would be implemented.

Some historical context for reference: #7647 (comment)

Activity

  1. eunomie commented on Jan 27, 2026

    @eunomie
    Member

    I'm trying to summarise my understanding of default vs defaultPath. Feel free to comment or fix what I'm saying. And maybe I'm missing some details.

    We are trying to work on two different aspects at the same time:

    • a set of features we want every SDK to implement, for instance to have default values (and for this specific case, the default value for a directory is its path)
    • an experience as native as possible, each SDK should rely on the language possibilities

    On Go SDK, default values are not something. So we came with pragma

    func (m *MyModule) echo(
            // +default="bar"
            foo string,
            // +defaultPath="my-sub-dir"
            src *dagger.Directory,
    ) string {

    In Python (and I guess in typescript) it means we are not using default pragma/annotation/decorator but relying on the default language capacities:

    def echo(self, foo: str = "bar") -> str:
    echo(foo = "bar"): string {

    But this can't be applied the same way to complex types like directory: while the pragma in Go, specified as a comment, can be used to create the complex value, we can't have a complex type equals a string.

    def echo(self, foo: str = "bar", src: dagger.Directory = "my-sub-dir")

    This is not valid.

    So we have a specific defaultPath annotation:

    def echo(self, foo: str = "bar", src: Annotated[dagger.Directory, DefaultPath("my-sub-dir")]) -> str:

    and basically the same thing in typescript:

    echo(foo = "bar", @argument({ defaultPath: "my-sub-dir" }) src: Directory): string {

    With that, I'm seeing multiple ways to align that.

    1. only use default, but keep it optional in the usage for simple types
    def echo(self, foo: str = "bar", src: Annotated[dagger.Directory, Default("my-sub-dir")]) -> str:
    def echo(self, foor: Annotated[str, Default("bar")], src: Annotated[dagger.Directory, Default("my-sub-dir")]) -> str:
    echo(foo = "bar", @argument({ default: "my-sub-dir" }) src: Directory): string {
    echo(@argument({ default: "bar" }) foo: string, @argument({ default: "my-sub-dir" }) src: Directory): string {
    1. use factories / helpers to create default values
    def echo(self, foo: str = "bar", src = dagger.DefaultDirectory("my-sub-dir")) -> str:
    echo(foo = "bar", src = defaultDirectory("my-sub-dir")): string {

    My concern with this option 2 is that we might still need some extra annotations and things will start to be more complexe:

    func (m *MyModule) echo(
            // +default="bar"
            foo string,
            // +defaultPath="my-sub-dir"
            // +ignore=["*", "!**/*.md"]
            src *dagger.Directory,
    ) string {
    def echo(self, foo: str = "bar",
      src: Annotated[dagger.Directory, Default("my-sub-dir"), Ignore(["*", "!**/*.md"])]) -> str:
    echo(foo = "bar", @argument({ default: "my-sub-dir", ignore: ["*", "!**/*.md"] }) src: Directory): string {

    If we mix that with the "native way" with factories/helper I'm not seeing that working very well. Or it means the ignore must be an argument of the helper, like:

    def echo(self, foo: str = "bar", src = dagger.DefaultDirectory("my-sub-dir", ["*", "!**/*.md"])) -> str:
    echo(foo = "bar", src = defaultDirectory("my-sub-dir", ["*", "!**/*.md"])): string {

    That's doable, but is it really better?

    FTR Java is closer to Go here, with the usage of a default annotation:

    public String echo(@Default("bar") String foo, @DefaultPath("my-sub-dir") @Ignore({"*", "!**/*.md"}) Directory src) {

    So the question that remains is to know if there is anything that really prevent us to rename defaultPath to default in python and typescript. If that's doable (and we can keep defaultPath for compatibility reasons for some time) then I'm not seeing any reason to not do it.
    That way we can extend default across all languages to handle more cases, like the from of a container.


    Note: on the typedef side, when we are registering the functions and their arguments, we can still keep withDefaultValue and withDefaultPath if that makes sense. The SDKs only can do the magic here. Or this is not an issue and we can also rely only on withDefaultValue, I haven't looked at this area.

  2. locked and limited conversation to collaborators on Mar 25, 2026
  3. converted this issue into a discussion #12797 on Mar 25, 2026
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