pulumi/pulumi · error
resources file contains invalid URN for %q: %w
Error message
resources file contains invalid URN for %q: %w
What it means
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.
Source
Thrown at pkg/cmd/pulumi/do/do_resource_upsert.go:538
return nil, nil
}
f, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("open resources file: %w", err)
}
defer contract.IgnoreClose(f)
var refs map[string]string
if err := json.NewDecoder(f).Decode(&refs); err != nil {
return nil, fmt.Errorf("parse resources file: %w", err)
}
for name, rawURN := range refs {
if name == "" {
return nil, errors.New("resources file contains an empty resource name")
}
urn, err := resource.ParseURN(rawURN)
if err != nil {
return nil, fmt.Errorf("resources file contains invalid URN for %q: %w", name, err)
}
refs[name] = string(urn)
}
return refs, nil
}
func resourceReferenceInfos(
resources map[string]string, snap *deploy.Snapshot,
) (map[string]plugin.ConvertSnippetResourceReference, error) {
if len(resources) == 0 {
return nil, nil
}
statesByURN := map[resource.URN]*pkgresource.State{}
providersByRef := map[string]*pkgresource.State{}
if snap != nil {
for _, state := range snap.Resources {
if state == nil {View on GitHub (pinned to 793f7b2e16)
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.
Example fix
// before
{"my-bucket": "my-bucket-id-123"}
// after
{"my-bucket": "urn:pulumi:stg::proj::aws:s3/bucket:Bucket::my-bucket"} Defensive patterns
Strategy: validation
Validate before calling
for name, urn := range refs {
if !strings.HasPrefix(urn, "urn:pulumi:") || len(strings.Split(urn, "::")) != 4 {
return fmt.Errorf("entry %q has malformed URN %q", name, urn)
}
} Prevention
- 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.
When it happens
Trigger: A resources file value like "my-bucket" (bare name), a truncated URN, or a URN with wrong segment counts is supplied to runStatefulSnippetUpdate/Patch.
Common situations: Hand-written URNs with wrong segment counts, URNs copied from logs with truncation, or using resource IDs instead of URNs in the file.
Related errors
- resources file contains an empty resource name
- resource %s is not a provider (type=%s); --provider must nam
- %q is not a valid resource URN %s
- call self must have a known urn property of type string
- duplicate import '%v' of type '%v'
AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31).
Data as JSON: /api/errors/c8788c1c1a34e886.
Report an issue: GitHub.