{"record":{"id":"c8788c1c1a34e886","repo":"pulumi/pulumi","slug":"resources-file-contains-invalid-urn-for-q-w","errorCode":null,"errorMessage":"resources file contains invalid URN for %q: %w","messagePattern":"resources file contains invalid URN for %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cmd/pulumi/do/do_resource_upsert.go","lineNumber":538,"sourceCode":"\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\n}\n\nfunc resourceReferenceInfos(\n\tresources map[string]string, snap *deploy.Snapshot,\n) (map[string]plugin.ConvertSnippetResourceReference, error) {\n\tif len(resources) == 0 {\n\t\treturn nil, nil\n\t}\n\n\tstatesByURN := map[resource.URN]*pkgresource.State{}\n\tprovidersByRef := map[string]*pkgresource.State{}\n\tif snap != nil {\n\t\tfor _, state := range snap.Resources {\n\t\t\tif state == nil {","sourceCodeStart":520,"sourceCodeEnd":556,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/cmd/pulumi/do/do_resource_upsert.go#L520-L556","documentation":"Each value in the resources file must parse as a valid Pulumi URN via resource.ParseURN. If a value is not a well-formed URN, the file is rejected with this wrapped error naming the offending resource.","triggerScenarios":"A resources file value like \"my-bucket\" (bare name), a truncated URN, or a URN with wrong segment counts is supplied to runStatefulSnippetUpdate/Patch.","commonSituations":"Hand-written URNs with wrong segment counts, URNs copied from logs with truncation, or using resource IDs instead of URNs in the file.","solutions":["Copy the exact URN from `pulumi stack export` (fields named \"urn\") rather than writing it by hand.","Check URN structure: urn:pulumi:<stack>::<project>::<type>::<name> — four double-colon separated parts after the prefix.","Re-generate the resources file via the upsert flow instead of manual construction."],"exampleFix":"// before\n{\"my-bucket\": \"my-bucket-id-123\"}\n// after\n{\"my-bucket\": \"urn:pulumi:stg::proj::aws:s3/bucket:Bucket::my-bucket\"}","handlingStrategy":"validation","validationCode":"for name, urn := range refs {\n  if !strings.HasPrefix(urn, \"urn:pulumi:\") || len(strings.Split(urn, \"::\")) != 4 {\n    return fmt.Errorf(\"entry %q has malformed URN %q\", name, urn)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy URNs verbatim from `pulumi stack export`.","Never substitute resource IDs for URNs in resources files.","Validate URN shape in CI before invoking stateful commands."],"tags":["urn","validation","resources-file"],"backgroundTag":"invalid-urn","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}