You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now a module that has the same name as a core type (e.g. Module, Container, etc.) will eventually result in an error. This is not only due to conflicts in the SDK code (depending on the SDK language) but ultimately also on the graphql schema level.
At a bare minimum, we should error out in dagger mod init if a module has a name that will result in a conflict. This is probably the right starting place.
Even better would be to handle this transparently so that even on the graphql schema level there's no possibility for conflicts like this. Namespacing doesn't fix this because the main module object is just the name of the module. The only way I can think of is to separate the names of the objects in the graphql schema and the names used by SDKs for codegen.
This is totally possible, but will require small-to-medium sized updates to every SDK's codegen logic
This can also be done in the future transparently, so doesn't need to be now or never
This got hit in the real-world by @shykes while working on our CI due to a non-core dep being named Git.
The workaround of renaming the dep from git->coolgit in dagger.json worked as intended, which is okay but obviously not ideal or obvious.
However the way it failed was interesting/concerning.
His module, which had a dep named Git and thus overrode Query.git to be his dependency's implementation. The module then received an argument of type Directory whose dagql id included a call to the coreQuery.git implementation.
When the module resolved the Directory, it ended up using Query.git from the dependency rather than core.
The behavior here should have been that something in the ID specified which Query.git it referred to and called that.
Maybe the way to think about this is that when a module resolves an arg received from another caller module, that arg's dagql ID needs to be evaluated in the dagql server of the caller module?
We include the module digest inside dagql Calls, so there might be a lot of plumbing in place to do this already?
I'll throw this in the next milestone for now since it seems like a ticking time bomb in terms of user confusion, with the only saving grace being there's a relatively low-pain fix if you know what's happening (rename dependencies)
Actually this gets a bit worse, in the github.com/shykes/git module itself the same conflict will happen (due to the fact that modules are served access to their own APIs)...
That in particular is an additional layer of annoying to deal with. The only way I can think of is that when serving self APIs, we don't serve them under Query.<modname>, we instead always serve them at Query.self.
This would be aligned with the changes we need to make to codegen to support self calls in the API anyways, so might work out fine?
❯ dagger call
✔ connect 0.2s
✘ load module 3.0s
! input: failed to get schema: failed to get schema for module "test": type "Env" is already defined by module "daggercore"
│ ✔ finding module configuration 0.3s
│ ✔ initializing module 2.8s
│ ✘ inspecting module metadata 0.0s
│ ! input: failed to get schema: failed to get schema for module "test": type "Env" is already defined by module "daggercore"
This is confusing - because this should be namespaced! In fact, looking at the results of namespacing manually, we can see that Env2 gets correctly namespaced to TestEnv2, but that Env is skipped. This is because of the logic here:
So, while it's trivial to ensure that we namespace Env for the Module.WithObject call at the top-level, it then becomes unclear what the return type for Test should be when it's returning Env. At the moment, the API can't distinguish between Env declared in this module, and Env declared in the core API.
It feels like we need a more complex API to deal with this here? As one idea, we actually know in each SDK whether a type is a generated type or not - we could attach that to WithObject, instead of automagically trying to determine it.
One note, is that if I rename the type to TestEnv it actually works as well - since this skips the namespacing in the engine, since it's actually already namespaced:
Activity
sipsma commentedon Sep 20, 2024
This got hit in the real-world by @shykes while working on our CI due to a non-core dep being named
Git.git->coolgitindagger.jsonworked as intended, which is okay but obviously not ideal or obvious.However the way it failed was interesting/concerning.
His module, which had a dep named
Gitand thus overrodeQuery.gitto be his dependency's implementation. The module then received an argument of typeDirectorywhose dagql id included a call to the coreQuery.gitimplementation.When the module resolved the
Directory, it ended up usingQuery.gitfrom the dependency rather than core.The behavior here should have been that something in the ID specified which
Query.gitit referred to and called that.sipsma commentedon Sep 20, 2024
I'll throw this in the
nextmilestone for now since it seems like a ticking time bomb in terms of user confusion, with the only saving grace being there's a relatively low-pain fix if you know what's happening (rename dependencies)cc @jedevc, just for your radar
sipsma commentedon Sep 21, 2024
Actually this gets a bit worse, in the
github.com/shykes/gitmodule itself the same conflict will happen (due to the fact that modules are served access to their own APIs)...That in particular is an additional layer of annoying to deal with. The only way I can think of is that when serving self APIs, we don't serve them under
Query.<modname>, we instead always serve them atQuery.self.jedevc commentedon Apr 8, 2025
So a specific case came up in discord earlier: https://discord.com/channels/707636530424053791/1359007453907386368/1359179295532257411
Take the following go module
test:If I try and run this module, I get:
This is confusing - because this should be namespaced! In fact, looking at the results of namespacing manually, we can see that
Env2gets correctly namespaced toTestEnv2, but thatEnvis skipped. This is because of the logic here:dagger/core/module.go
Lines 484 to 492 in 06194e5
We should always namespace this top-level object - since it's being created by the user.
However, it's not as simple as that - see the generated go code in
invokefor this module:So, while it's trivial to ensure that we namespace
Envfor theModule.WithObjectcall at the top-level, it then becomes unclear what the return type forTestshould be when it's returningEnv. At the moment, the API can't distinguish betweenEnvdeclared in this module, andEnvdeclared in the core API.It feels like we need a more complex API to deal with this here? As one idea, we actually know in each SDK whether a type is a generated type or not - we could attach that to
WithObject, instead of automagically trying to determine it.One note, is that if I rename the type to
TestEnvit actually works as well - since this skips the namespacing in the engine, since it's actually already namespaced:dagger/core/gqlformat.go
Line 35 in 20bab13