{"record":{"id":"305a5f7cf06d4afd","repo":"microsoft/aspire","slug":"unsupported-value-type-value-gettype-305a5f","errorCode":null,"errorMessage":"Unsupported value type {value.GetType()}","messagePattern":"Unsupported value type (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs","lineNumber":309,"sourceCode":"                }\n\n                if (expr.StringFormats[index] is string format)\n                {\n                    val = BicepFormattingHelpers.FormatBicepExpression(val, format);\n                }\n\n                args[index++] = val;\n            }\n\n            return (FormattableStringFactory.Create(expr.Format, args), finalSecretType);\n        }\n\n        if (value is IManifestExpressionProvider manifestExpressionProvider)\n        {\n            return (AllocateParameter(manifestExpressionProvider, secretType), secretType);\n        }\n\n        throw new NotSupportedException($\"Unsupported value type {value.GetType()}\");\n    }\n\n    private static BicepValue<string> ResolveValue(object val)\n    {\n        return val switch\n        {\n            BicepValue<string> s => s,\n            string s => s,\n            ProvisioningParameter p => p,\n            FormattableString fs => BicepFunction.Interpolate(fs),\n            _ => throw new NotSupportedException($\"Unsupported value type {val.GetType()}\")\n        };\n    }\n\n    public void BuildWebSite(AzureResourceInfrastructure infra)\n    {\n        _infrastructure = infra;\n","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs#L291-L327","documentation":"ProcessValue converts environment-variable/argument values for the website into Bicep parameters or secret references. It understands strings, primitives, IManifestExpressionProvider, and secret reference types; when it receives a value type outside its handled set it throws this NotSupportedException reporting the concrete CLR type via value.GetType().","triggerScenarios":"Calling ProcessValue (directly or through environment/argument processing) with an unhandled object type — e.g. a custom IValueProvider that is not an IManifestExpressionProvider, a complex object, a BicepValue, or a raw Guid/DateTime not converted to string.","commonSituations":"Custom annotations supplying bespoke value types to WithEnvironment/args; passing connection-string or endpoint objects instead of their string/manifest forms; version changes where new value types (e.g. BicepValue inputs) were introduced but ProcessValue wasn't extended.","solutions":["Convert the value to a supported type before it reaches ProcessValue: use a string, a primitive, or an IManifestExpressionProvider (e.g. ReferenceExpression).","If passing connection/endpoint objects, pass their .Value / expression form rather than the wrapper object.","If you own a custom value provider, implement IManifestExpressionProvider so it resolves to a manifest expression.","Inspect the reported type in the message to identify exactly which value failed and add a case for it if you're modifying the library."],"exampleFix":"// before\napi.WithEnvironment(\"MY_VALUE\", new MyCustomValue());\n// after\napi.WithEnvironment(\"MY_VALUE\", ReferenceExpression.Create($\"{myCustomValue}\")); // or .ToString()/string value","handlingStrategy":"type-guard","validationCode":"static bool IsSupportedProcessValueType(object v) =>\n    v is string or IManifestExpressionProvider or IAzureKeyVaultSecretReference || v is int or long or bool;","typeGuard":"if (value is not (string or IManifestExpressionProvider))\n    throw new ArgumentException($\"Convert {value.GetType().Name} to a string, ReferenceExpression, or secret reference before App Service processing.\");","tryCatchPattern":"try { var (param, _) = ctx.ProcessValue(value, secretType); }\ncatch (NotSupportedException ex) when (ex.Message.StartsWith(\"Unsupported value type\"))\n{\n    value = value.ToString(); // or wrap in ReferenceExpression\n    var (param, _) = ctx.ProcessValue(value, secretType);\n}","preventionTips":["Pass strings, primitives, or IManifestExpressionProvider values to WithEnvironment/args on App Service projects.","Unwrap connection/endpoint objects to their expression or string form first.","Implement IManifestExpressionProvider on custom value providers."],"tags":["azure-app-service","type-mismatch","environment-variables","publishing"],"backgroundTag":"type-mismatch","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}