{"record":{"id":"187759d5ef5fdd8a","repo":"dagger/dagger","slug":"load-workspace-arg-q-w","errorCode":null,"errorMessage":"load workspace arg %q: %w","messagePattern":"load workspace arg %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/modfunc.go","lineNumber":740,"sourceCode":"\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\tctxArgVals[i] = &argInput{\n\t\t\t\t\targName: arg.Name,\n\t\t\t\t\tval:     ctxVal,\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}\n\n\t\t// Process workspace arguments - automatically inject workspace when not set\n\t\tworkspaceArgVals := make([]*argInput, len(workspaceArgs))\n\t\tfor i, arg := range workspaceArgs {\n\t\t\teg.Go(func() error {\n\t\t\t\twsVal, err := fn.loadWorkspaceArg(ctx, srv)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"load workspace arg %q: %w\", arg.Name, err)\n\t\t\t\t}\n\n\t\t\t\tworkspaceArgVals[i] = &argInput{\n\t\t\t\t\targName: arg.Name,\n\t\t\t\t\tval:     wsVal,\n\t\t\t\t}\n\n\t\t\t\treturn nil\n\t\t\t})\n\t\t}\n\n\t\t// Process user-defined user defaults for objects (and lists of objects)\n\t\ttype userDefaultArgInput struct {\n\t\t\targName string\n\t\t\tval     dagql.Input\n\t\t}\n\t\tuserDefaultVals := make([]*userDefaultArgInput, len(userDefaults))\n\t\tfor i, userDefault := range userDefaults {","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/modfunc.go#L722-L758","documentation":"DynamicInputsForCall automatically injects the current workspace (module directory) into arguments typed for it when not supplied. If fn.loadWorkspaceArg fails, the error is wrapped as \"load workspace arg %q\" naming the argument that would have received the workspace.","triggerScenarios":"Calling a function with a parameter qualifying for automatic workspace injection, while resolving the workspace itself fails — e.g. the module has no valid source directory in this context.","commonSituations":"Running dagger call outside a valid module context; the module source directory failed to load; git worktree/checkout issues in CI making the workspace unresolvable.","solutions":["Run the command from within a valid dagger module directory (where dagger.json exists).","Pass the directory argument explicitly instead of relying on workspace injection.","Verify the module source directory loads correctly (git status, file permissions).","Check the wrapped inner error for the underlying workspace load failure."],"exampleFix":"# before (run outside module)\ncd /somewhere && dagger call build\n# after\ncd /path/to/my-module && dagger call build","handlingStrategy":"validation","validationCode":"# Ensure the command runs inside a valid dagger module (dagger.json present)\nif [ ! -f dagger.json ]; then echo \"not in a dagger module\"; exit 1; fi","typeGuard":null,"tryCatchPattern":"_, err := fn.Call(ctx, args)\nif err != nil && strings.Contains(err.Error(), \"load workspace arg\") {\n\t// supply the workspace directory explicitly\n\targs[\"workspace\"] = dag.Host().Directory(\".\")\n\t_, err = fn.Call(ctx, args)\n}","preventionTips":["Always run dagger call from a directory containing dagger.json.","Pass workspace-typed arguments explicitly in scripts that may run outside the module root.","Verify git worktrees/checkouts in CI include the module source.","Check the inner error for the actual workspace load failure."],"tags":["go","dagger","workspace","arguments"],"backgroundTag":"workspace-injection-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}