{"record":{"id":"d9c87aed47a71876","repo":"pulumi/pulumi","slug":"resources-file-references-q-as-s-but-that-resou","errorCode":null,"errorMessage":"resources file references %q as %s, but that resource was not found in the stack","messagePattern":"resources file references %q as (.+?), but that resource was not found in the stack","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/do/do_resource_upsert.go","lineNumber":575,"sourceCode":"\t\t\t\tcontinue\n\t\t\t}\n\t\t\tstatesByURN[state.URN] = state\n\t\t\tif sdkproviders.IsProviderType(state.Type) {\n\t\t\t\tref, err := sdkproviders.NewReference(state.URN, state.ID)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn nil, fmt.Errorf(\"could not build provider reference for %s: %w\", state.URN, err)\n\t\t\t\t}\n\t\t\t\tprovidersByRef[ref.String()] = state\n\t\t\t}\n\t\t}\n\t}\n\n\trefs := make(map[string]plugin.ConvertSnippetResourceReference, len(resources))\n\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)","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/do/do_resource_upsert.go#L557-L593","documentation":"Every name in the resources file must correspond to a resource present in the target stack snapshot. If the URN is not found among snapshot states, the whole reference resolution aborts with this error naming the resource and URN.","triggerScenarios":"Resources file maps a name to a URN that does not exist in the selected stack — wrong stack selected, resource deleted since the file was generated, or URN drift after renames.","commonSituations":"Switching stacks (dev vs prod) while reusing the same resources file; the file references a resource removed by a previous `pulumi destroy` or refresh.","solutions":["Regenerate the resources file against the current stack so all URNs exist.","Confirm the intended stack is selected (--stack flag) and matches where the resources file was produced.","Remove stale entries from the resources file for resources no longer in the stack."],"exampleFix":"// before (stale entry)\n{\"old-bucket\": \"urn:pulumi:stg::proj::aws:s3/bucket:Bucket::old-bucket\"}\n// after (removed)\n{\"my-bucket\": \"urn:pulumi:stg::proj::aws:s3/bucket:Bucket::my-bucket\"}","handlingStrategy":"validation","validationCode":"exported, _ := pc.exportStack(ctx, stackRef)\ninStack := map[string]bool{}\nfor _, r := range exported.Resources { inStack[string(r.URN)] = true }\nfor name, urn := range refs {\n  if !inStack[urn] {\n    return fmt.Errorf(\"%s (%s) not in stack; regenerate resources file\", name, urn)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Regenerate the resources file per stack; never share it across stacks.","Remove entries for destroyed resources.","Diff resources-file URNs against a fresh stack export before each run."],"tags":["not-found","snapshot","resources-file"],"backgroundTag":"resource-not-found-in-stack","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}