{"record":{"id":"8ec1426c63666f10","repo":"pulumi/pulumi","slug":"generation-failed-w-8ec142","errorCode":null,"errorMessage":"generation failed: %w","messagePattern":"generation failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/packageworkspace/packageworkspace.go","lineNumber":440,"sourceCode":"\tif err != nil {\n\t\treturn \"\", err\n\t}\n\ttmpDir, err := os.MkdirTemp(\"\", \"pulumi-package-\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"unable to make temp dir: %w\", err)\n\t}\n\ts, err := w.servers(ctx, language, tmpDir, pkg.Reference())\n\tif err != nil {\n\t\treturn \"\", errors.Join(err, os.RemoveAll(tmpDir))\n\t}\n\n\tdiags, err := s.lang.GeneratePackage(ctx, tmpDir, string(jsonBytes), nil, s.pctx.LoaderAddr(), nil, true /* local */)\n\tif err != nil {\n\t\treturn \"\", errors.Join(err, s.Close(), os.RemoveAll(tmpDir))\n\t}\n\n\tif diags.HasErrors() {\n\t\treturn \"\", errors.Join(fmt.Errorf(\"generation failed: %w\", diags),\n\t\t\ts.Close(), os.RemoveAll(tmpDir))\n\t}\n\n\treturn tmpDir, s.Close()\n}\n\n// Run a package from a directory, parameterized by params.\nfunc (w Workspace) RunPackage(\n\tctx context.Context, rootDir, pluginPath string, params plugin.ParameterizeParameters,\n\toriginalSpec workspace.PackageSpec,\n) (plugin.Provider, error) {\n\ttracer := otel.Tracer(\"pulumi-cli\")\n\tctx, span := diagutils.StartSpan(ctx, tracer, \"run-plugin\",\n\t\ttrace.WithAttributes(\n\t\t\tattribute.String(\"path\", pluginPath),\n\t\t))\n\tdefer span.End()\n","sourceCodeStart":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/packageworkspace/packageworkspace.go#L422-L458","documentation":"Wraps the diagnostic set returned by the language host's GeneratePackage call when code generation reports errors (diags.HasErrors()). The schema was received and a temp dir created, but the per-language SDK generator produced fatal diagnostics. The message joins the diagnostics with cleanup errors (closing the plugin and removing the temp dir).","triggerScenarios":"A plugin/SDK generation run where s.lang.GeneratePackage returns diagnostics containing errors — e.g. invalid or unsupported schema constructs, unsupported types, codegen bugs for the target language.","commonSituations":"Generating SDKs for providers with exotic or invalid schemas, newer schema features unsupported by the installed language codegen, mismatched provider/plugin versions, or custom parameterized packages with unusual types.","solutions":["Read the joined diagnostics in the error for the specific codegen failures","Update the provider plugin and Pulumi CLI to latest versions","Regenerate with a different language target to isolate whether the schema or the language generator is at fault","Fix or work around the offending schema types in the provider","Report an issue if valid schema triggers codegen errors"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"tmpDir, err := generatePackage(...)\nif err != nil {\n    var dgerr interface{ HasErrors() bool }\n    if errors.As(err, &dgerr) && dgerr.HasErrors() {\n        log.Printf(\"codegen diagnostics: %v\", err) // inspect joined diags\n    }\n    return err\n}","preventionTips":["Keep provider plugins and Pulumi CLI up to date","Test schema generation for each target language in CI","Avoid exotic/unsupported schema constructs in providers"],"tags":["codegen","schema","sdk-generation"],"backgroundTag":"codegen-diagnostics-error","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}