{"record":{"id":"8a665ce2f30f9cca","repo":"dagger/dagger","slug":"load-current-workspace-w","errorCode":null,"errorMessage":"load current workspace: %w","messagePattern":"load current workspace: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/workspace_context.go","lineNumber":79,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"get bound workspace ID: %w\", err)\n\t\t}\n\t\treturn dagql.NewID[*Workspace](wsID), nil\n\t}\n\tif srv == nil {\n\t\treturn nil, nil\n\t}\n\t// A running module function must pass a Workspace to its dependencies\n\t// explicitly, so it doesn't silently inherit its caller's.\n\tif inModuleFunction, err := callerInModuleFunction(ctx); err != nil {\n\t\treturn nil, err\n\t} else if inModuleFunction {\n\t\treturn nil, nil\n\t}\n\tvar ws dagql.ObjectResult[*Workspace]\n\tif err := srv.Select(ctx, srv.Root(), &ws, dagql.Selector{\n\t\tField: \"currentWorkspace\",\n\t}); err != nil {\n\t\treturn nil, fmt.Errorf(\"load current workspace: %w\", err)\n\t}\n\twsID, err := ws.ID()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get current workspace ID: %w\", err)\n\t}\n\treturn dagql.NewID[*Workspace](wsID), nil\n}\n\n// WithBoundWorkspaceArgs supplies the workspace for any required Workspace\n// argument in specs that named doesn't already carry.\n//\n// Callers that assemble a selector themselves — the entrypoint proxies building\n// their inner constructor call, like ModTreeNode.DagqlValue — have to fill a\n// required Workspace before selecting, since dagql's injection hook runs after\n// the non-null check.\nfunc WithBoundWorkspaceArgs(\n\tctx context.Context,\n\tsrv *dagql.Server,","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/workspace_context.go#L61-L97","documentation":"This error wraps any failure from srv.Select when resolving the `currentWorkspace` root field on the session's dagql server, inside workspaceArgValue. workspaceArgValue is called when assembling a required (non-null) Workspace-typed argument that the caller left unset: it tries the context-bound Workspace first, and if none is bound (and the call is not inside a running module function), it falls back to loading the ambient current workspace. If that GraphQL selection fails for any reason (no current workspace, resolver error, server/instance issues), the underlying error is wrapped with this message and propagated to the caller building the selector (boundWorkspaceArgs / boundWorkspaceInput).","triggerScenarios":"Calling WithBoundWorkspaceArgs (or otherwise triggering boundWorkspaceInput/boundWorkspaceArgs) for a spec with a required Workspace argument, when: (a) no Workspace is bound via WorkspaceToContext, (b) the call is not inside a module function (callerInModuleFunction false), and (c) srv.Select(ctx, srv.Root(), &ws, {Field: \"currentWorkspace\"}) fails — e.g. the session has no currentWorkspace, the resolver errors, or the server/root is in a bad state.","commonSituations":"Running a module function or framework entrypoint (check, group, up proxies) outside of a workspace-aware session so `currentWorkspace` cannot resolve; stale/errored engine session where the root query can't serve currentWorkspace; calling library APIs that auto-fill Workspace args from a plain SDK client session with no workspace loaded; version mismatches where the served schema no longer exposes currentWorkspace.","solutions":["Run the call inside a context where a Workspace is bound — use WorkspaceToContext(ctx, ws) so workspaceArgValue takes the bound-Workspace path and never selects currentWorkspace.","Explicitly pass the Workspace argument in `named` inputs to WithBoundWorkspaceArgs so the unset-arg fallback never runs.","Check the wrapped (%w) underlying error: if it says the field doesn't exist or no workspace is current, verify the engine/session actually has a current workspace (dagger CLI session started in a module/workspace directory).","If the call legitimately has no workspace, ensure it's inside a module function (callerInModuleFunction true) so nil is returned and dagql reports the missing argument by name instead of this wrapped failure."],"exampleFix":"// before: assembling args with no workspace bound\nnamed := core.WithBoundWorkspaceArgs(ctx, srv, specs, named)\n// after: bind the workspace first so currentWorkspace is never queried\nws, err := srv.Select(ctx, srv.Root(), ...currentWorkspace...) // or obtain otherwise\nctx = core.WorkspaceToContext(ctx, ws)\nnamed := core.WithBoundWorkspaceArgs(ctx, srv, specs, named)","handlingStrategy":"try-catch","validationCode":"// ensure a workspace is bound before building args\nif _, ok := core.WorkspaceFromContext(ctx); !ok {\n    // load/bind current workspace first\n    var ws dagql.ObjectResult[*core.Workspace]\n    if err := srv.Select(ctx, srv.Root(), &ws, dagql.Selector{Field: \"currentWorkspace\"}); err != nil {\n        return fmt.Errorf(\"no workspace available: %w\", err)\n    }\n    ctx = core.WorkspaceToContext(ctx, ws)\n}","typeGuard":"func hasBoundWorkspace(ctx context.Context) bool {\n    ws, ok := core.WorkspaceFromContext(ctx)\n    return ok && ws.Self() != nil\n}","tryCatchPattern":"named := core.WithBoundWorkspaceArgs(ctx, srv, specs, named) // errors are returned, not panicked\nif err != nil { // propagate from your own wrapper that calls boundWorkspaceInput\n    return fmt.Errorf(\"could not resolve workspace for required argument: %w\", err)\n}","preventionTips":["Always bind the workspace with WorkspaceToContext at group/tool dispatch so auto-fill never needs currentWorkspace.","Pass Workspace arguments explicitly in `named` inputs whenever you know the workspace.","Keep the dagger session started inside a workspace/module directory so currentWorkspace resolves.","Pin SDK and CLI versions together to avoid schema drift around currentWorkspace."],"tags":["go","dagger","workspace","dagql","graphql-selection"],"backgroundTag":"current-workspace-unresolved","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}