{"record":{"id":"024167f74d280285","repo":"pulumi/pulumi","slug":"load-package-for-token-s-w","errorCode":null,"errorMessage":"load package for token %s: %w","messagePattern":"load package for token (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pcl/runtime/interpreter.go","lineNumber":721,"sourceCode":"\t}\n\n\treturn outputs, nil\n}\n\nfunc (i *Interpreter) lookupResource(ctx context.Context, token string) (*schema.Resource, error) {\n\tpkg, mod, typ, diags := pcl.DecomposeToken(token, hcl.Range{})\n\tcontract.Assertf(!diags.HasErrors(), \"invalid token format for resource token %s\", token)\n\n\ttoken = fmt.Sprintf(\"%s:%s:%s\", pkg, mod, typ)\n\tpkgName := pkg\n\tif pkg == \"pulumi\" && mod == \"providers\" {\n\t\tpkgName = typ\n\t}\n\n\tdescriptor := i.lookupPackageDescriptor(pkgName)\n\tpkgref, err := i.loader.LoadPackageReferenceV2(ctx, descriptor)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"load package for token %s: %w\", token, err)\n\t}\n\tif pkg == \"pulumi\" && mod == \"providers\" {\n\t\treturn pkgref.Provider()\n\t}\n\tresources := pkgref.Resources()\n\tschemaResource, ok, err := resources.Get(token)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"get resource from package for token %s: %w\", token, err)\n\t}\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"get resource from package for token %s\", token)\n\t}\n\treturn schemaResource, nil\n}\n\nfunc (i *Interpreter) lookupFunction(ctx context.Context, token string) (*schema.Function, error) {\n\tpkg, mod, typ, diags := pcl.DecomposeToken(token, hcl.Range{})\n\tcontract.Assertf(!diags.HasErrors(), \"invalid token format for function token %s\", token)","sourceCodeStart":703,"sourceCodeEnd":739,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/pcl/runtime/interpreter.go#L703-L739","documentation":"Interpreter.lookupResource resolves a PCL resource token (pkg:module:type) to a schema resource. It first loads the package via i.loader.LoadPackageReferenceV2 using the package descriptor; if loading fails, it returns \"load package for token %s: %w\". This means the provider package's schema could not be fetched, parsed, or parameterized — not that the specific resource is missing.","triggerScenarios":"registerResource → lookupResource with a token whose package cannot be loaded: schema download fails (no network/bad plugin cache), the package version does not exist, or a parameterized package descriptor is invalid.","commonSituations":"Offline execution without a cached provider schema; specifying a plugin version that was never published; corrupted ~/.pulumi/plugins schema cache; typo in the package name in the PCL import; parameterized provider (e.g. kubernetes) with bad parameterization value.","solutions":["Check the wrapped error for the actual load failure (download, parse, version)","Run `pulumi plugin install resource <pkg> <version>` to warm the local schema cache","Verify the package name and version in the PCL import / PackageDescriptors are correct and published","If parameterized, confirm the Parameterization name/version/value match the base package schema","Check network/proxy access to the provider's schema download URL"],"exampleFix":"// before: import referencing a nonexistent version\nimport * as aws from \"@pulumi/aws\"; // version 99.0.0 in descriptor\n// after: pin a published version\n// PackageDescriptor: { Name: \"aws\", Version: semver.MustParse(\"6.0.0\") }","handlingStrategy":"validation","validationCode":"// pre-flight: ensure the package schema can be loaded before running the program\n_, err := loader.LoadPackageReferenceV2(ctx, &schema.PackageDescriptor{Name: pkg, Version: ver})\nif err != nil {\n    return fmt.Errorf(\"pre-flight schema load for %s failed: %w\", pkg, err)\n}","typeGuard":null,"tryCatchPattern":"res, err := interp.Run(ctx, program)\nif err != nil && strings.Contains(err.Error(), \"load package for token\") {\n    // retry after warming the plugin cache, or report a schema-availability problem\n    return fmt.Errorf(\"provider schema unavailable: %w\", err)\n}","preventionTips":["Run `pulumi plugin install resource <pkg> <version>` before executing interpreted programs","Pin only published provider versions in PackageDescriptors","Validate parameterization values against the base package schema","Check network/proxy access to schema download URLs in CI"],"tags":["pcl","schema","package-loading"],"backgroundTag":"package-schema-load-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}