{"record":{"id":"21f2bd92a66bd5d7","repo":"pulumi/pulumi","slug":"error-parsing-pcl-w","errorCode":null,"errorMessage":"error parsing pcl: %w","messagePattern":"error parsing pcl: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/convert/convert.go","lineNumber":326,"sourceCode":"\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// if the target directory is a subdirectory of the source directory,\n\t\t\t\t\t\t// skip copying it over\n\t\t\t\t\t\treturn sourceAbsPath != targetAbsPath\n\t\t\t\t\t}\n\n\t\t\t\t\treturn file.Name() != \"Pulumi.yaml\" &&\n\t\t\t\t\t\tpath.Ext(file.Name()) != \".pp\"\n\t\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"copying files from source directory: %w\", err)\n\t\t\t}\n\n\t\t\tpackageBlockDescriptors, ds, err := getPackagesToGenerateSdks(sourceDirectory)\n\t\t\tdiags = append(diags, ds...)\n\t\t\tif err != nil {\n\t\t\t\treturn diags, fmt.Errorf(\"error parsing pcl: %w\", err)\n\t\t\t}\n\n\t\t\terr = generateAndLinkSdksForPackages(\n\t\t\t\tpCtx,\n\t\t\t\tstdout,\n\t\t\t\tlanguage,\n\t\t\t\ttargetDirectory,\n\t\t\t\tpackageBlockDescriptors,\n\t\t\t\tgenerateOnly,\n\t\t\t\tcmdCmd.NewDefaultRegistry(ctx, lm, ws, proj, cmdutil.Diag(), e),\n\t\t\t)\n\t\t\tif err != nil {\n\t\t\t\treturn diags, fmt.Errorf(\"error generating packages: %w\", err)\n\t\t\t}\n\n\t\t\treturn diags, nil\n\t\t}\n\t}","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/convert/convert.go#L308-L344","documentation":"This error wraps a failure from `getPackagesToGenerateSdks(sourceDirectory)` during `pulumi convert`'s PCL-to-language path. That helper parses the source directory's PCL files with the pcl binder to find `package` blocks so SDKs can be generated for them. If the PCL source does not parse (syntax errors or binder diagnostics escalated to an error), the conversion aborts with \"error parsing pcl\".","triggerScenarios":"Running `pulumi convert --from pcl --language <lang>` where the source directory contains .pp files with PCL syntax errors, unrecognized constructs, or a binder failure inside getPackagesToGenerateSdks.","commonSituations":"Hand-written or hand-edited PCL programs; PCL produced by an older/newer converter that emits constructs the current binder cannot parse; typos in resource declarations or invalid config types in .pp files.","solutions":["Run `pulumi convert --language pcl` first and inspect the returned hcl.Diagnostics for the exact file/line of the parse failure","Fix the reported PCL syntax/type errors in the .pp files in the source directory","Upgrade the Pulumi CLI to the latest version in case the source was generated by a newer converter","Reduce the program to a minimal .pp file and re-add declarations until the offending construct is found"],"exampleFix":"// before (invalid PCL)\nresource bucket \"aws:s3:Bucket\" {\n    acl = true\n}\n// after\nresource bucket \"aws:s3:Bucket\" {\n    acl = \"private\"\n}","handlingStrategy":"validation","validationCode":"// Validate PCL before converting\nout, err := exec.Command(\"pulumi\", \"convert\", \"--from\", \"pcl\", \"--language\", \"pcl\", \"--out\", tmpDir).CombinedOutput()\nif err != nil {\n    return fmt.Errorf(\"PCL failed to parse, fix these diagnostics first:\\n%s\", out)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var diags hcl.Diagnostics\n    if errors.As(err, &diags) {\n        for _, d := range diags {\n            fmt.Printf(\"%s:%d: %s\\n\", d.Subject.Filename, d.Subject.Start.Line, d.Summary)\n        }\n    }\n}","preventionTips":["Lint .pp files by round-tripping through `pulumi convert --language pcl` in CI","Keep Pulumi CLI and any producing converter plugin versions in sync","Validate generated PCL immediately after generation, before editing"],"tags":["pcl","parser","convert","hcl-diagnostics"],"backgroundTag":"pcl-parse-error","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}