{"record":{"id":"3af6baf2cfd1200c","repo":"pulumi/pulumi","slug":"open-resources-file-w","errorCode":null,"errorMessage":"open resources file: %w","messagePattern":"open resources file: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/do/do_resource_upsert.go","lineNumber":524,"sourceCode":"\t\t\t\"whose values are the URNs of existing resources in the stack, for example:\\n\"+\n\t\t\t\"  {\\n\"+\n\t\t\t\"    \\\"myBucket\\\": \\\"urn:pulumi:dev::my-project::aws:s3/bucket:Bucket::my-bucket\\\",\\n\"+\n\t\t\t\"    \\\"myVpc\\\":    \\\"urn:pulumi:dev::my-project::aws:ec2/vpc:Vpc::my-vpc\\\"\\n\"+\n\t\t\t\"  }\\n\"+\n\t\t\t\"Identifiers for existing stack resources are auto-assigned; run `pulumi do show-resources`\\n\"+\n\t\t\t\"to see them. Entries in this file take precedence over any auto-assigned identifier.\")\n\tcmd.Flags().BoolVar(yes, \"yes\", false,\n\t\t\"Automatically approve and perform the operation without a confirmation prompt\")\n\taddInputFlags(cmd, \"input\", inputs)\n}\n\nfunc readResourceReferences(path string) (map[string]string, error) {\n\tif path == \"\" {\n\t\treturn nil, nil\n\t}\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"open resources file: %w\", err)\n\t}\n\tdefer contract.IgnoreClose(f)\n\n\tvar refs map[string]string\n\tif err := json.NewDecoder(f).Decode(&refs); err != nil {\n\t\treturn nil, fmt.Errorf(\"parse resources file: %w\", err)\n\t}\n\tfor name, rawURN := range refs {\n\t\tif name == \"\" {\n\t\t\treturn nil, errors.New(\"resources file contains an empty resource name\")\n\t\t}\n\t\turn, err := resource.ParseURN(rawURN)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"resources file contains invalid URN for %q: %w\", name, err)\n\t\t}\n\t\trefs[name] = string(urn)\n\t}\n\treturn refs, nil","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/do/do_resource_upsert.go#L506-L542","documentation":"readResourceReferences opens the JSON resources file passed to the command. If os.Open fails (missing path, no permissions), the OS error is wrapped as \"open resources file: ...\".","triggerScenarios":"Passing a --resources-file path that does not exist, a directory path, or a file the process cannot read to runStatefulSnippetUpdate or runStatefulSnippetPatch.","commonSituations":"Typoed file path, running from a different working directory with a relative path, a previous step that was supposed to generate the resources file failed silently, or restrictive file permissions.","solutions":["Check the path exists and is readable: `ls -l <path>` or `cat <path>`.","Use an absolute path or run from the correct working directory.","Ensure the upstream step (e.g. resource upsert) that writes the resources file completed successfully before invoking the update/patch."],"exampleFix":"// before\npulumi resource update --resources-file ./resorces.json\n// after\npulumi resource update --resources-file ./resources.json","handlingStrategy":"validation","validationCode":"info, err := os.Stat(path)\nif err != nil || info.IsDir() {\n  return fmt.Errorf(\"resources file %q missing or not a regular file\", path)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute paths for --resources-file.","Verify the generator step produced the file before consuming it.","Check file permissions in CI environments."],"tags":["file-io","cli","resources-file"],"backgroundTag":"file-not-found","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}