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
{{ message }}
Repository navigation
🐞 0.21.0 gives result *core.ModuleObject is detached error #13246
Not sure, might be related to our own modules. I would appreciate it if someone can point me at how to troubleshoot/further debug to deliver more info in this issue.
I checked the release notes, but couldn't identity the root cause, or changes I have to make in our modules.
After upgrading from Dagger 0.20.8 to 0.21.0, module methods started failing with:
result *core.ModuleObject is detached
The issue was caused by storing dependency module objects inside exported module
state, for example keeping a *dagger.SomeDependencyModule field on a module struct
and returning that struct from chained methods.
That pattern worked in 0.20.8, but in 0.21.0 the dependency module object can
become detached when Dagger serializes/deserializes module state between calls.
This can fail because Tool is itself a module object. After WithConfig returns
MyModule, the stored Tool object may no longer be attached to the active query
graph.
Fix
Do not store dependency module objects in module state. Store only serializable
configuration or core Dagger values, then reconstruct the dependency module object
when needed.
After replacing persisted dependency module fields with plain state and helper
methods that rebuild dependency clients, the module works on Dagger 0.21.0. The
fix keeps module state serializable and avoids carrying detached ModuleObject
instances across function boundaries.
This is most likely a bug, will see if I can repro and fix if so
EDIT:
On deeper inspection I am less sure about what's happening here.
@marcofranssen When I try to do a repro close to the description even on v0.20.8 I get this error: object "Repro" field "Tool" cannot reference external type from dependency module "tool"
Which is expected. What I am confused about is that it never worked, even on that version. Can you give a more detailed repro in case I am missing something?
If others hitting this can provide their own repro I would highly appreciate it. *core.ModuleObject is detached shouldn't happen and indicates a bug. However the original repro in the description doesn't yet have enough details for me to actually reproduce the bug yet.
With another user I did fine a case where using cache="never" could cause this, so would like to know if that's why everyone else is hitting this or if there's something else that could also cause this error.
Activity
marcofranssen commentedon May 28, 2026
After upgrading from Dagger 0.20.8 to 0.21.0, module methods started failing with:
result *core.ModuleObject is detached
The issue was caused by storing dependency module objects inside exported module
state, for example keeping a *dagger.SomeDependencyModule field on a module struct
and returning that struct from chained methods.
That pattern worked in 0.20.8, but in 0.21.0 the dependency module object can
become detached when Dagger serializes/deserializes module state between calls.
Example Failure Pattern
Before:
This can fail because Tool is itself a module object. After WithConfig returns
MyModule, the stored Tool object may no longer be attached to the active query
graph.
Fix
Do not store dependency module objects in module state. Store only serializable
configuration or core Dagger values, then reconstruct the dependency module object
when needed.
After:
Result
After replacing persisted dependency module fields with plain state and helper
methods that rebuild dependency clients, the module works on Dagger 0.21.0. The
fix keeps module state serializable and avoids carrying detached ModuleObject
instances across function boundaries.
marcofranssen commentedon May 28, 2026
Feel free to close the issue, leaving it open as this might be something that has to be improved in documentation.
sipsma commentedon Jun 1, 2026
This is most likely a bug, will see if I can repro and fix if soEDIT:
On deeper inspection I am less sure about what's happening here.
@marcofranssen When I try to do a repro close to the description even on v0.20.8 I get this error:
object "Repro" field "Tool" cannot reference external type from dependency module "tool"Which is expected. What I am confused about is that it never worked, even on that version. Can you give a more detailed repro in case I am missing something?
wvell commentedon Jun 1, 2026
@marcofranssen Thank you for your detailed issue. We ran into the same issue and your solution seems to fix it for us.
sipsma commentedon Jun 1, 2026
If others hitting this can provide their own repro I would highly appreciate it.
*core.ModuleObject is detachedshouldn't happen and indicates a bug. However the original repro in the description doesn't yet have enough details for me to actually reproduce the bug yet.With another user I did fine a case where using
cache="never"could cause this, so would like to know if that's why everyone else is hitting this or if there's something else that could also cause this error.marcofranssen commentedon Jun 2, 2026
@sipsma yes we do have some
cache="never"in the nested modules indeed.@sipsma if we can connect on slack or discord I could show you how to reproduce.