{"record":{"id":"4d0608d4bda6e717","repo":"microsoft/semantic-kernel","slug":"argument-propertyname-has-a-value-that-doesn-t-4d0608","errorCode":null,"errorMessage":"Argument '{propertyName}' has a value that doesn't support automatic encoding. Set {nameof(InputVariable.AllowDangerouslySetContent)} to 'true' for this argument and implement custom encoding, or provide the value as a string.","messagePattern":"Argument '(.+?)' has a value that doesn't support automatic encoding\\. Set (.+?) to 'true' for this argument and implement custom encoding, or provide the value as a string\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Extensions/PromptTemplates.Liquid/LiquidPromptTemplate.cs","lineNumber":234,"sourceCode":"        }\n\n        var valueType = propertyValue.GetType();\n\n        var underlyingType = Nullable.GetUnderlyingType(valueType) ?? valueType;\n\n        if (underlyingType == typeof(string))\n        {\n            var stringValue = (string)propertyValue;\n            return stringValue.Replace(ColonString, ReservedString);\n        }\n\n        if (this.IsSafeType(underlyingType))\n        {\n            return propertyValue;\n        }\n\n        // For complex types, throw an exception if dangerous content is not allowed\n        throw new NotSupportedException(\n            $\"Argument '{propertyName}' has a value that doesn't support automatic encoding. \" +\n            $\"Set {nameof(InputVariable.AllowDangerouslySetContent)} to 'true' for this argument and implement custom encoding, \" +\n            \"or provide the value as a string.\");\n    }\n\n    /// <summary>\n    /// Determines if a type is considered safe and doesn't require encoding.\n    /// </summary>\n    /// <param name=\"type\">The type to check.</param>\n    /// <returns>True if the type is safe, false otherwise.</returns>\n    private bool IsSafeType(Type type)\n    {\n        return type == typeof(byte) ||\n               type == typeof(sbyte) ||\n               type == typeof(bool) ||\n               type == typeof(ushort) ||\n               type == typeof(short) ||\n               type == typeof(char) ||","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Extensions/PromptTemplates.Liquid/LiquidPromptTemplate.cs#L216-L252","documentation":"Thrown by LiquidPromptTemplate's value-encoding path when an input variable's value is a complex type that is neither a string nor a type whitelisted by `IsSafeType`, and the argument's `AllowDangerouslySetContent` is false. Liquid encodes safe primitives automatically; for arbitrary objects it refuses to silently stringify potentially dangerous content and instead requires the caller to opt into raw injection.","triggerScenarios":"Passing an object/struct/dictionary as an input variable value (e.g. a POCO, a JObject, a List<T>) where the corresponding InputVariable.AllowDangerouslySetContent is false.","commonSituations":"Binding a domain model directly into a prompt instead of pre-serializing to a string; upgrading a variable from string to object without updating InputVariables config.","solutions":["Serialize the value to a string before passing it into KernelArguments.","Set `InputVariable.AllowDangerouslySetContent = true` on that variable AND implement your own sanitization.","Restructure the input so only primitive/safe-typed values reach the template."],"exampleFix":"// before\narguments[\"user\"] = myUserObject; // complex type\n// after\narguments[\"user\"] = JsonSerializer.Serialize(myUserObject);","handlingStrategy":"validation","validationCode":"// Stringify complex values before adding them to KernelArguments:\nforeach (var k in arguments.Names) {\n    var v = arguments[k];\n    if (v is not string && v is not null && !IsPrimitive(v.GetType())) {\n        arguments[k] = JsonSerializer.Serialize(v);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-serialize objects to strings before they reach the template.","Document which InputVariables require AllowDangerouslySetContent and why."],"tags":["liquid","prompt-template","security","encoding"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}