Repository navigation
feat(schema): add optional workspace arg to asSDK - #13727
Merged
Merged
Conversation
This was referenced Jul 23, 2026
TomChv
approved these changes
Jul 24, 2026
Member
There was a problem hiding this comment.
I'm giving an early approval so we can merge it whenever it's possible.
Next step after:
- Bump the engine version in CI (optional but it always feel good to see green checks 😸)
- Merge dagger/go-sdk#14 and replicate the changes on other SDK's.
vito
force-pushed
the
as-sdk-explicit-workspace
branch
from
July 24, 2026 16:55
bc7ff8b to
0d52b63
Compare
currentModule.asSDK read the ambient current workspace to resolve the module's SDK-role config. Disabling workspace inheritance for dependency modules makes that ambient workspace unavailable: a module driven as a dependency no longer inherits its caller's workspace, so asSDK failed with "no current workspace" the moment such a module tried to enumerate its managed modules. Take the workspace as an explicit, required argument and resolve SDK-role data against it. Config reads route through that workspace's own rootfs or owner client, so there is no sandbox concern, and a synthetic workspace that carries config is honored like a detected one. Both callers that reach asSDK already hold the workspace to pass: a dependency receives it explicitly, and a generator run by the framework has it injected. Thread the injected workspace through the TestSDKGeneratorOwnsClients fixture's generate function into AsSDK so it keeps resolving its clients. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
currentModuleAsSDKClientModuleSource resolved a client's module against the session's ambient current workspace. A module driven as a dependency no longer has one, and a workspace carrying overlay edits would resolve against stale content. Carry the workspace asSDK was called on as a BoundWorkspace on each CurrentModuleAsSDKClient — a full object result, so it represents overlay and synthetic workspaces, not just client-bound ones — and resolve the client's module source against it. The workspace is persisted by result id and re-attached on decode, so a reloaded client still resolves against the right workspace, matching how generator and check groups carry theirs. Extend TestSDKGeneratorOwnsClients to bind a client to a local module and resolve its source, exercising the resolver end to end. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Making Workspace a required argument on currentModule.asSDK is the ideal end state, but requiring it up front makes the rollout painful: every SDK that reaches asSDK has to be updated in lockstep before anything works. Accept the workspace as an optional argument for now. When it is omitted, fall back to resolving the ambient current workspace, exactly as asSDK did before the argument existed, so existing callers keep working untouched. The fallback selects currentWorkspace to get an ObjectResult, so the bound workspace carried on each client is still populated for module-source resolution. FIXMEs mark the intended end state: make the argument required and drop the fallback once every caller passes a workspace explicitly. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
as-sdk-explicit-workspace
branch
from
July 24, 2026 18:51
0d52b63 to
57046f0
Compare
This was referenced Jul 27, 2026
TomChv
added a commit
to dagger/typescript-sdk
that referenced
this pull request
Jul 27, 2026
Mirrors dagger/go-sdk#14, pairs with dagger/dagger#13727. `currentModule.asSDK` now takes an explicit workspace argument instead of implicitly resolving against the current workspace, so modules(ws) resolves its SDK-managed module list against the workspace it was actually handed. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
to dagger/python-sdk
that referenced
this pull request
Jul 27, 2026
dagger/dagger#13727 added an optional `workspace` argument to `currentModule.asSDK`, so the SDK-role data resolves against an explicitly passed workspace instead of the ambient current workspace — which dependency modules cannot see since workspace inheritance was disabled. Use it instead of the `ws.sdk(name: currentModule.name)` workaround: looking the SDK up by module entry name only worked by coincidence of the entry being named after the module, and it read the workspace's SDK list rather than the current module's own as-sdk role. Signed-off-by: Tom Chauveau <[email protected]>
TomChv
added a commit
that referenced
this pull request
Aug 6, 2026
currentModule.asSDK took the workspace as an optional argument and fell back to the ambient current workspace when omitted. That was a stopgap: #13727 landed the argument as optional to avoid updating every SDK in lockstep, with FIXMEs marking the required argument as the end state. The rollout is done — the go, typescript, python and php SDK modules all call asSDK(workspace: ws) as of 2026-07-27 — so require it and drop the fallback. Nullable was also a lie in practice: since #13229 a module driven as a dependency does not inherit its caller's workspace, so the fallback either failed with "no current workspace" or, for a synthetic or overlaid workspace, silently read the wrong config. It also forced the clunky CurrentModuleAsSDKOpts{Workspace: ws} call shape in Go, and the equivalent opts objects in TypeScript, Python and Rust. Signed-off-by: Tom Chauveau <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
currentModule.asSDKnow takes an optionalworkspace: Workspaceargument and resolves the module's SDK-role data (the modules and clients it manages) against that workspace, instead of reading the ambient current workspace. When the argument is omitted it falls back to the current workspace, so existing callers keep working unchanged.Why
#13229 disabled workspace inheritance for dependency modules: a module invoked as a dependency no longer inherits its caller's current workspace. But
currentModule.asSDKresolved its config by callingCurrentWorkspace(ctx), so the moment an SDK module was driven as a dependency and tried to enumerate its managed modules, it failed withno current workspace: workspace not loaded.a3679718e1fixed the same class of failure for theWorkspace.generators().run()path by restoring the workspace owner's client context before running codegen. This does the equivalent for the direct/explicit path: rather than reaching for an ambient workspace that dependency modules intentionally can't see,asSDKtakes the workspace explicitly. Both callers that reach it already hold one — a dependency is handed it, and a generator run by the framework has it injected.Making the argument required is the ideal end state, but requiring it up front makes the rollout painful — every SDK that reaches
asSDKwould have to be updated in lockstep before anything works. So the argument is optional for now, defaulting to the current workspace, withFIXMEs marking the intended end state: make it required and drop the fallback once every caller passes a workspace explicitly.How
asSDK(workspace:)loads the passed workspace (or resolvescurrentWorkspacewhen omitted) and reads its config. Reads route through the workspace's own rootfs / owner client, so there is no sandbox concern, and a synthetic (value) workspace that carries config is honored like a detected one.asSDKclient carries the workspace it was resolved on as aBoundWorkspace, so a client's module source resolves against that workspace rather than the ambient one.TestSDKGeneratorOwnsClientsfixture so its+generatefunction receives the injected workspace and threads it intoAsSDK(now viaCurrentModuleAsSDKOpts).AsSDK(opts ...CurrentModuleAsSDKOpts)and the schema exposesworkspace: ID(nullable).