{"record":{"id":"de38ba2d2b341e61","repo":"hashicorp/nomad","slug":"cannot-serialize-s","errorCode":null,"errorMessage":"cannot serialize %s","messagePattern":"cannot serialize (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"helper/pluginutils/hclutils/util.go","lineNumber":176,"sourceCode":"\tcase t.IsObjectType():\n\t\tresult := map[string]interface{}{}\n\n\t\tfor k := range t.AttributeTypes() {\n\t\t\tav := val.GetAttr(k)\n\t\t\tavv, err := ctyValueToInterface(av)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tresult[k] = avv\n\t\t}\n\t\treturn result, nil\n\n\tcase t.IsCapsuleType():\n\t\treturn val.EncapsulatedValue(), nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"cannot serialize %s\", t.FriendlyName())\n\t}\n}\n\nfunc smallestNumber(b *big.Float) interface{} {\n\tif v, acc := b.Int64(); acc == big.Exact {\n\t\tif int64(int(v)) == v {\n\t\t\treturn int(v)\n\t\t}\n\t\treturn v\n\t}\n\n\tv, _ := b.Float64()\n\treturn v\n}\n\n// GetStdlibFuncs returns the set of stdlib functions.\nfunc GetStdlibFuncs() map[string]function.Function {\n\treturn map[string]function.Function{","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/helper/pluginutils/hclutils/util.go#L158-L194","documentation":"ctyValueToInterface handles primitive, list/tuple, map/object, set, and capsule types. Any other cty type (e.g. a type without a defined Go mapping) reaches the default branch and fails with 'cannot serialize <FriendlyName>'.","triggerScenarios":"Converting a cty.Value whose type falls outside the supported set — typically an exotic capsule-ish or dynamically typed value reaching the default branch after the switch.","commonSituations":"Custom providers/plugins embedding capsule types into config values; upgrades where new cty types appear but the converter was not extended.","solutions":["Avoid putting the unsupported type in the converted payload; convert only supported cty types.","If it is a capsule type you control, extract data via EncapsulatedValue before conversion.","Extend ctyValueToInterface with a case for the named type (its FriendlyName is in the message)."],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"cannot serialize %s\", t.FriendlyName())\n// after\ncase t.IsCapsuleType():\n    return val.EncapsulatedValue(), nil\n// (add handling instead of erroring)","handlingStrategy":"validation","validationCode":"t := val.Type()\nsupported := t.IsPrimitiveType() || t.IsListType() || t.IsMapType() ||\n    t.IsSetType() || t.IsTupleType() || t.IsObjectType() || t.IsCapsuleType()\nif !supported {\n    return fmt.Errorf(\"cannot serialize %s\", t.FriendlyName())\n}","typeGuard":null,"tryCatchPattern":"m, err := CtyValueToMapInterface(val)\nif err != nil && strings.HasPrefix(err.Error(), \"cannot serialize\") {\n    return fmt.Errorf(\"unsupported config value type: %w\", err)\n}","preventionTips":["Restrict plugin config to JSON-representable cty types","Extend converter cases when adding new types","Pin and test against the cty version you depend on"],"tags":["cty","serialization","go"],"backgroundTag":"unsupported-serialization-type","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}