{"record":{"id":"7f446924a655ad90","repo":"dagger/dagger","slug":"stage-module-generated-context-w","errorCode":null,"errorMessage":"stage module generated context: %w","messagePattern":"stage module generated context: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/workspace_module_init.go","lineNumber":198,"sourceCode":"\tmoduleDiff, err := s.workspaceModuleInitConfigDiff(ctx, baseDir, args, relPath, runtimeRef)\n\tif err != nil {\n\t\treturn res, scope, err\n\t}\n\tconfigRelPath := staged.ConfigFile\n\n\tdag, err := core.CurrentDagqlServer(ctx)\n\tif err != nil {\n\t\treturn res, scope, fmt.Errorf(\"dagql server: %w\", err)\n\t}\n\n\tupdatedDir := baseDir\n\tupdatedDir, err = workspaceWithFile(ctx, dag, updatedDir, configRelPath, newConfigBytes)\n\tif err != nil {\n\t\treturn res, scope, fmt.Errorf(\"stage workspace config update: %w\", err)\n\t}\n\tupdatedDir, err = workspaceWithDirectoryOverlay(ctx, dag, updatedDir, moduleDiff)\n\tif err != nil {\n\t\treturn res, scope, fmt.Errorf(\"stage module generated context: %w\", err)\n\t}\n\n\tengineChanges, err := workspaceMigrationChanges(ctx, updatedDir, baseDir)\n\tif err != nil {\n\t\treturn res, scope, err\n\t}\n\n\tsdkArgs, err := coresdk.DecodeInitArgs(args.Args)\n\tif err != nil {\n\t\treturn res, scope, err\n\t}\n\tmoduleInitializer, ok := loadedSDK.AsModuleInitializer()\n\tif !ok {\n\t\treturn res, scope, fmt.Errorf(\"%q does not support module init\", args.SDK)\n\t}\n\tsdkWorkspace, err := rootAnchoredWorkspace(ctx, parent)\n\tif err != nil {\n\t\treturn res, scope, err","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/workspace_module_init.go#L180-L216","documentation":"This error wraps a failure from workspaceWithDirectoryOverlay, which merges the module's generated context (the new dagger-module.toml diff) into the staged workspace rootfs via Directory.withDirectory. It runs immediately after the config-file staging step in initModuleChanges; failure here means the engine could not overlay the module config diff directory onto the workspace tree.","triggerScenarios":"Calling Workspace.initModule when the dagql withDirectory overlay fails: the source diff Directory ID cannot be computed (src.ID() failure), the module diff object is invalid, or the dagql query itself errors.","commonSituations":"The module config diff failed to build cleanly upstream (e.g. a marshal problem surfacing as an unusable Directory); content-addressed blob for the diff missing on the engine; dagql version skew between SDK and engine.","solutions":["Read the wrapped inner error — 'source directory id: ...' points at ID computation on the diff; retry module init first.","Restart the dagger engine session to clear missing/unresolvable cache blobs, then retry.","Ensure the dagger SDK/CLI versions match the engine (`dagger version`); upgrade both if skewed.","If reproducible on a minimal workspace, file a dagger issue with the wrapped error — this stage is fully engine-internal."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm no module config already exists at the target path\nfor _, f := range []string{\"dagger-module.toml\", \"dagger.json\"} {\n    if _, err := ws.Directory().File(filepath.Join(path, f)).Contents(ctx); err == nil {\n        return fmt.Errorf(\"module config already exists at %s\", path)\n    }\n}","typeGuard":null,"tryCatchPattern":"if _, err := ws.InitModule(ctx, args); err != nil {\n    if strings.Contains(err.Error(), \"stage module generated context\") {\n        // restart engine session and retry from a fresh workspace\n        return retryAfterEngineRestart(args)\n    }\n    return err\n}","preventionTips":["Retry init after engine restart — overlay failures are frequently transient blob issues","Pin matching dagger CLI/SDK and engine versions","Run init from a clean workspace state (no half-applied previous init)","Ensure sufficient disk space for the engine's content-address store"],"tags":["dagql","workspace","overlay","module-init"],"backgroundTag":"dagql-select-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"}