{"record":{"id":"4f9f7098b08a342b","repo":"pulumi/pulumi","slug":"malformed-resource-reference-packageversion-must","errorCode":null,"errorMessage":"malformed resource reference: packageVersion must be a string","messagePattern":"malformed resource reference: packageVersion must be a string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resource/stack/deployment.go","lineNumber":1117,"sourceCode":"\t\t\t\t\tplaintext, plainOk := objmap[\"plaintext\"].(string)\n\t\t\t\t\tif (!cipherOk && !plainOk) || (plainOk && cipherOk) {\n\t\t\t\t\t\treturn resource.PropertyValue{}, errors.New(\n\t\t\t\t\t\t\t\"malformed secret value: exactly one of `ciphertext` or `plaintext` must be supplied\",\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tsecret := &apitype.SecretV1{\n\t\t\t\t\t\tSig:        resource.SecretSig,\n\t\t\t\t\t\tPlaintext:  plaintext,\n\t\t\t\t\t\tCiphertext: ciphertext,\n\t\t\t\t\t}\n\t\t\t\t\treturn deserializeSecret(ctx, secret, dec)\n\t\t\t\tcase resource.ResourceReferenceSig:\n\t\t\t\t\tvar packageVersion string\n\t\t\t\t\tif packageVersionV, ok := objmap[\"packageVersion\"]; ok {\n\t\t\t\t\t\tpackageVersion, ok = packageVersionV.(string)\n\t\t\t\t\t\tif !ok {\n\t\t\t\t\t\t\treturn resource.PropertyValue{},\n\t\t\t\t\t\t\t\terrors.New(\"malformed resource reference: packageVersion must be a string\")\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\turnStr, ok := objmap[\"urn\"].(string)\n\t\t\t\t\tif !ok {\n\t\t\t\t\t\treturn resource.PropertyValue{}, errors.New(\"malformed resource reference: missing urn\")\n\t\t\t\t\t}\n\t\t\t\t\turn := resource.URN(urnStr)\n\n\t\t\t\t\t// deserializeID handles two cases, one of which arose from a bug in a refactoring of resource.ResourceReference.\n\t\t\t\t\t// This bug caused the raw ID PropertyValue to be serialized as a map[string]any. In the normal case, the\n\t\t\t\t\t// ID is serialized as a string.\n\t\t\t\t\tdeserializeID := func() (string, bool, error) {\n\t\t\t\t\t\tidV, ok := objmap[\"id\"]\n\t\t\t\t\t\tif !ok {\n\t\t\t\t\t\t\treturn \"\", false, nil\n\t\t\t\t\t\t}\n","sourceCodeStart":1099,"sourceCodeEnd":1135,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/resource/stack/deployment.go#L1099-L1135","documentation":"A resource-reference property value (ResourceReferenceSig) contains a \"packageVersion\" field that is not a JSON string. The deserializer requires it be a string semver and throws this error.","triggerScenarios":"Deserializing a PropertyValue with resource-reference signature whose objmap[\"packageVersion\"] is a number, object, or other non-string JSON value.","commonSituations":"JSON tooling writing numeric versions (e.g. 3 instead of \"3.0.0\"), hand-edited state, or buggy third-party generators of deployment documents.","solutions":["Change packageVersion to a string (e.g. \"5.0.0\") in the serialized property","Remove packageVersion entirely if the version is unknown","Regenerate the deployment/state via official Pulumi tooling"],"exampleFix":"// before\n{\"sig\":\"...\", \"urn\":\"...\", \"packageVersion\": 5}\n// after\n{\"sig\":\"...\", \"urn\":\"...\", \"packageVersion\": \"5.0.0\"}","handlingStrategy":"type-guard","validationCode":"if pv, ok := objmap[\"packageVersion\"]; ok {\n\tif _, isStr := pv.(string); !isStr {\n\t\treturn errors.New(\"packageVersion must be a string\")\n\t}\n}","typeGuard":"func hasStringPackageVersion(m map[string]any) bool {\n\tv, ok := m[\"packageVersion\"]; if !ok { return true }; _, isStr := v.(string); return isStr\n}","tryCatchPattern":null,"preventionTips":["Always JSON-quote version strings, including bare versions like \"3\"","Use typed structs (apitype.ResourceReferenceV1) instead of raw maps when generating state","Add schema validation to any tool that writes deployment documents"],"tags":["deserialization","resource-reference","type-mismatch"],"backgroundTag":"malformed-resource-reference","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}