{"record":{"id":"982108cd7ad59812","repo":"microsoft/aspire","slug":"unsupported-value-type-val-gettype-982108","errorCode":null,"errorMessage":"Unsupported value type {val.GetType()}","messagePattern":"Unsupported value type (.+?)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs","lineNumber":320,"sourceCode":"        }\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\n        // Check for deployment slot\n        // If specified, update hostnames to endpoint references\n        BicepValue<string>? deploymentSlotValue = null;\n        if (environmentContext.Environment.DeploymentSlotParameter is not null || environmentContext.Environment.DeploymentSlot is not null)\n        {\n            deploymentSlotValue = environmentContext.Environment.DeploymentSlotParameter != null\n                ? environmentContext.Environment.DeploymentSlotParameter.AsProvisioningParameter(infra)\n                : environmentContext.Environment.DeploymentSlot!;\n\n            UpdateHostNameForSlot(deploymentSlotValue);\n        }","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs#L302-L338","documentation":"ResolveValue converts a processed value object into a BicepValue<string> for the generated WebSite resource. The switch handles BicepValue<string>, string, ProvisioningParameter, and FormattableString; any other type falls through to this NotSupportedException, which reports the offending type via val.GetType().","triggerScenarios":"ResolveValue is invoked (from 'conditional'/'value' helpers while building the WebSite) with a value that is none of BicepValue<string>, string, ProvisioningParameter, or FormattableString — e.g. an int, bool, or BicepValue<int> passed straight through without conversion.","commonSituations":"Passing non-string primitives (port numbers, flags) directly as website property values; custom website customization annotations feeding typed BicepValue<int>/bool into paths that expect string-typed values; internal refactors that changed the set of value types flowing into ResolveValue.","solutions":["Convert the value before calling: numbers/bools to string (value.ToString(CultureInfo.InvariantCulture)).","Wrap an interpolated value as a FormattableString (e.g. $\"{other}\") so BicepFunction.Interpolate handles it.","If it's a BicepValue of another element type, convert it to BicepValue<string> first.","If you're extending the library, add a case for the reported type in the ResolveValue switch."],"exampleFix":"// before\nResolveValue(targetPort); // int\n// after\nResolveValue(targetPort.ToString(CultureInfo.InvariantCulture));","handlingStrategy":"type-guard","validationCode":"static bool IsResolvableBicepInput(object v) =>\n    v is BicepValue<string> or string or ProvisioningParameter or FormattableString;","typeGuard":"if (val is not (BicepValue<string> or string or ProvisioningParameter or FormattableString))\n    val = val switch { IFormattable f => f.ToString(null, CultureInfo.InvariantCulture), _ => val.ToString() };","tryCatchPattern":"try { bicepValue = ResolveValue(val); }\ncatch (NotSupportedException ex) when (ex.Message.StartsWith(\"Unsupported value type\"))\n{\n    bicepValue = ResolveValue(val.ToString() ?? string.Empty);\n}","preventionTips":["Convert numbers/bools to strings (with InvariantCulture) before feeding website property values.","Use FormattableString ($\"...\") for interpolated Bicep values.","Ensure typed BicepValue<T> values are BicepValue<string> for string-typed site properties."],"tags":["azure-app-service","bicep","type-mismatch","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"}