Workspace settings of an installed module are lost when the entrypoint depends on it and sorts before it
What is the issue?
A module installed in dagger.toml with [modules.<name>.settings] does not get those settings as constructor defaults when the workspace's entrypoint module also depends on it ([[dependencies]] in the entrypoint's dagger-module.toml) and the entrypoint's [modules.<key>] sorts before it alphabetically. Calling the installed module directly (dagger api call <module> ...) then runs its constructor without the setting. dagger module settings <module> still lists it, and the -vv trace shows it being passed along (ModuleSource.asModule(..., legacyWorkspaceConfigJson: "{...}")).
Renaming only the entrypoint's key so that it sorts after the dependency, or removing the entrypoint, makes the setting arrive. Nothing else changes. It is unrelated to caching: the result is the same when the constructor call is not cached.
As far as I can tell from the source at v1.0.0-beta.14:
- Workspace modules are loaded in sorted config-name order (
engine/server/session_workspaces.go,slices.Sort(names)). - When the entrypoint is served, its direct dependencies are served with it (
SkipConstructor: true). SchemaBuilder.With(core/moddeps.go) keeps the first module of a given name and drops the later, configured instance.
So the entrypoint's dependency instance, which has no WorkspaceConfig, ends up serving Query.<module>, and UserDefault's workspace-config path (core/modfunc.go) never applies. #14013 (one source installed under two names) looks related, but its fix does not cover this case.
I would expect the installed module to keep its settings regardless of the order of the names, as it does when no entrypoint depends on it.
Dagger version
dagger v1.0.0-beta.14 (06660c3c) darwin/arm64
Steps to reproduce
A workspace with two Go SDK modules, greeter and an entrypoint dev that depends on it:
greeter/main.go:
package main
type Greeter struct {
// +private
GatewayAddress string
}
func New(
// +optional
gatewayAddress string,
) *Greeter {
return &Greeter{GatewayAddress: gatewayAddress}
}
func (m *Greeter) Address() string {
return "addr=[" + m.GatewayAddress + "]"
}dev/dagger-module.toml:
name = "dev"
engineVersion = "v1.0.0-beta.14"
[runtime]
source = "go"
[[dependencies]]
name = "greeter"
source = "../greeter"dagger.toml:
[modules.dagger-go-sdk]
source = "github.com/dagger/go-sdk"
[modules.greeter]
source = "greeter"
[modules.greeter.settings]
gatewayAddress = "from-dagger-toml"
[sdks.go]
module = "dagger-go-sdk"
[sdks.go.scopes."greeter"]
is-module = true
name = "greeter"
[modules.dev]
entrypoint = true
source = "dev"
[sdks.go.scopes."dev"]
is-module = true
name = "dev"
clients = ["./greeter"]Then:
$ dagger api call greeter address
addr=[]With [modules.dev] renamed to [modules.zdev], which sorts after greeter:
$ dagger api call greeter address
addr=[from-dagger-toml]With the entrypoint removed from dagger.toml, the result is also addr=[from-dagger-toml].
Log output
With -vv in the failing case, both instances are loaded. The configured one carries the setting (ModuleSource.asModule(legacyNameOverride: "greeter", legacyWorkspaceConfigJson: "{\"gatewayAddress\":\"from-dagger-toml\"}")), next to the entrypoint's dependency loaded without it. Yet the constructor receives no value.
Source: dagger/dagger