{"record":{"id":"99a9df019653034f","repo":"dagger/dagger","slug":"failed-to-create-instance-for-module-q-w","errorCode":null,"errorMessage":"failed to create instance for module %q: %w","messagePattern":"failed to create instance for module %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/schema/modulesource.go","lineNumber":4232,"sourceCode":"\tif args.LegacyWorkspaceConfigJSON != \"\" {\n\t\tif err := mod.ApplyWorkspaceDefaultsToTypeDefs(ctx, dag); err != nil {\n\t\t\treturn inst, err\n\t\t}\n\t}\n\tif args.LegacyArgCustomizationsJSON != \"\" {\n\t\tvar customizations []*modules.ModuleConfigArgument\n\t\tif err := json.Unmarshal([]byte(args.LegacyArgCustomizationsJSON), &customizations); err != nil {\n\t\t\treturn inst, fmt.Errorf(\"decoding legacy arg customizations: %w\", err)\n\t\t}\n\t\tmod.LegacyArgCustomizations = customizations\n\t\tif err := mod.ApplyLegacyCustomizationsToTypeDefs(ctx, dag, customizations); err != nil {\n\t\t\treturn inst, err\n\t\t}\n\t}\n\n\tinst, err = dagql.NewObjectResultForCurrentCall(ctx, dag, mod)\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"failed to create instance for module %q: %w\", src.Self().ModuleName, err)\n\t}\n\treturn inst, nil\n}\n\n// load the given module source's dependencies as modules\n// BuildLegacyAsModuleArgs is the single builder for the asModule args salted\n// into AsModuleVariantDigest, so every load path yields one module identity.\nfunc BuildLegacyAsModuleArgs(\n\tnameOverride string,\n\tlegacyDefaultPath bool,\n\tdefaultPathContextSourceRef string,\n\tdefaultPathContextSourcePin string,\n\tconfigDefaults map[string]any,\n\tdefaultsFromDotEnv bool,\n\targCustomizations []*modules.ModuleConfigArgument,\n) ([]dagql.NamedInput, error) {\n\targs := []dagql.NamedInput{}\n\tif nameOverride != \"\" {","sourceCodeStart":4214,"sourceCodeEnd":4250,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/schema/modulesource.go#L4214-L4250","documentation":"The final step of asModule wraps the built core.Module in a dagql instance via dagql.NewObjectResultForCurrentCall, which registers the result with the current GraphQL call. If instance creation fails, the error is wrapped as 'failed to create instance for module %q' with the module name.","triggerScenarios":"Calling asModule where the module itself built successfully but dagql.NewObjectResultForCurrentCall fails — typically because there is no current dagql call context or an internal dagql allocation/registration error.","commonSituations":"Invoking the asModule resolver outside a proper GraphQL call context (tests, custom tooling calling core functions directly); internal engine bugs; resource exhaustion during instance registration.","solutions":["Inspect the wrapped inner error; this is almost always an engine-internal issue","Ensure asModule is invoked through the GraphQL API within a dagql call, not called directly from Go outside a server context","Retry the module load; transient engine failures can hit the instance registry","Report a bug with the inner error and engine version if it reproduces consistently"],"exampleFix":"// before (Go, direct call outside dagql)\ninst, err := schema.moduleSourceAsModule(ctx, src, args)\n// after: query via the client\nmod := dag.ModuleSource(dirPath).AsModule()","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { mod = src.asModule() } catch (e) { if (String(e).includes('failed to create instance for module')) { log.error('dagql instance failure:', e.cause ?? e) } throw e }","preventionTips":["Invoke asModule through the GraphQL/client API, never by calling core resolvers directly outside dagql","Keep engine updated; this is usually an internal engine issue","Include the inner cause and `dagger version` in bug reports if it persists"],"tags":["dagger","dagql","module"],"backgroundTag":"dagql-instance-creation-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"}