{"record":{"id":"7356e44d848acb1e","repo":"pulumi/pulumi","slug":"resources-file-reference-q-w","errorCode":null,"errorMessage":"resources file reference %q: %w","messagePattern":"resources file reference %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/do/do_resource_upsert.go","lineNumber":589,"sourceCode":"\tfor name, rawURN := range resources {\n\t\turn := resource.URN(rawURN)\n\t\tstate, ok := statesByURN[urn]\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"resources file references %q as %s, but that resource was not found in the stack\", name, urn)\n\t\t}\n\n\t\ttyp := state.Type\n\t\tpkg := typ.Package()\n\t\tif sdkproviders.IsProviderType(typ) {\n\t\t\tpkg = sdkproviders.GetProviderPackage(typ)\n\t\t}\n\t\tpackageReq := &codegenrpc.GetSchemaRequest{\n\t\t\tPackage: string(pkg),\n\t\t}\n\n\t\tproviderState, err := resourceReferenceProviderState(state, providersByRef)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"resources file reference %q: %w\", name, err)\n\t\t}\n\t\tif providerState != nil {\n\t\t\tproviderPackage := sdkproviders.GetProviderPackage(providerState.Type)\n\t\t\tschemaPackage, err := deployproviders.GetProviderName(providerPackage, providerState.Inputs)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"resources file reference %q: get provider name: %w\", name, err)\n\t\t\t}\n\t\t\tpackageReq.Package = string(schemaPackage)\n\n\t\t\tversion, err := deployproviders.GetProviderVersion(providerState.Inputs)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"resources file reference %q: get provider version: %w\", name, err)\n\t\t\t}\n\t\t\tif version != nil {\n\t\t\t\tpackageReq.Version = version.String()\n\t\t\t}\n\n\t\t\tdownloadURL, err := deployproviders.GetProviderDownloadURL(providerState.Inputs)","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/do/do_resource_upsert.go#L571-L607","documentation":"For each resources-file reference, resourceReferenceProviderState locates the owning provider's state. If that helper fails, the error is wrapped as \"resources file reference %q: ...\". This is a wrapping boundary — the cause (e.g. missing provider for the resource's package) is in the wrapped error.","triggerScenarios":"A referenced resource's provider state cannot be resolved — e.g. the resource depends on a provider that is absent from providersByRef because the snapshot lacks the provider resource, or provider/dependency linkage is inconsistent.","commonSituations":"Stack state missing provider resources after partial destroy or manual state surgery; resources referencing a provider configured in a different stack/project.","solutions":["Read the wrapped cause and run `pulumi refresh`/`pulumi up` to recreate missing provider resources in the stack.","Check `pulumi stack export` for provider resources of the referenced resource's package; re-import state if missing.","Regenerate the resources file excluding resources whose providers cannot be resolved, then address them individually."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for _, r := range exported.Resources {\n  if isProviderType(r.Type) { providerPkgs[r.Type.Package()] = true }\n}\nfor name, urn := range refs {\n  pkg := resource.URN(urn).Type().Package()\n  if !providerPkgs[pkg] {\n    return fmt.Errorf(\"reference %q needs a %s provider that is missing from the stack\", name, pkg)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure `pulumi up` has created all providers before running stateful reference commands.","Never partially destroy provider resources a snippet still depends on.","Inspect stack export for provider resources of each referenced package first."],"tags":["provider","snapshot","stateful-edit"],"backgroundTag":"missing-provider-state","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}