{"record":{"id":"23a16255668dab22","repo":"microsoft/aspire","slug":"unsupported-value-type-value-gettype","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.AppContainers/BaseContainerAppContext.cs","lineNumber":384,"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 BicepValue<string> AllocateKeyVaultSecretUriReference(IAzureKeyVaultSecretReference secretOutputReference)\n    {\n        var secret = secretOutputReference.AsKeyVaultSecret(Infra);\n\n        return secret.Properties.SecretUri;\n    }\n\n    protected ProvisioningParameter AllocateContainerImageParameter()\n        => AllocateParameter(new ContainerImageReference(resource));\n\n    protected BicepValue<string> AllocateContainerPortParameter()\n        => AllocateParameter(new ContainerPortReference(resource));\n\n    protected static BicepValue<int> AsInt(BicepValue<string> value)\n    {\n        return new FunctionCallExpression(new IdentifierExpression(\"int\"), value.Compile());","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.AppContainers/BaseContainerAppContext.cs#L366-L402","documentation":"ProcessValue in BaseContainerAppContext exhaustively maps supported value shapes (outputs, parameters, secret references, endpoint references, generic IManifestExpressionProvider, etc.) into Bicep parameters. If none match, it throws this NotSupportedException, meaning an unhandled value type was supplied to a container app's environment variables, args, or command line during publish.","triggerScenarios":"Passing a value of a type not handled by ProcessValue into WithEnvironment/WithArgs/WithEntrypoint/WithContainerRuntimeArgs on a container app resource during publish/generate, e.g., a custom IValueProvider implementation or an unsupported resource reference.","commonSituations":"Custom resource types emitting bespoke value providers; version mismatches where a newer reference type isn't handled by the installed Aspire.Hosting.Azure.AppContainers; typos like passing a builder instead of the underlying value.","solutions":["Convert the value to a supported type (string, FormattableString, or a resource's built-in reference type) before passing it.","Use the resource's documented reference APIs (e.g., endpoint .Url/.Host, key vault secret references) rather than custom wrappers.","Align package versions across Aspire.Hosting.* so all value-provider types are recognized."],"exampleFix":"// before\n.WithEnvironment(\"ENDPOINT\", new MyCustomEndpointProvider(endpointResource));\n\n// after\n.WithEnvironment(\"ENDPOINT\", endpointResource.GetEndpoint(\"https\").Url);","handlingStrategy":"type-guard","validationCode":"// Allow only documented reference/value types through to WithEnvironment/WithArgs.\nif (value is not (string or FormattableString or IManifestExpressionProvider or IValueProvider or IAzureKeyVaultSecretReference))\n    throw new NotSupportedException($\"Unsupported container app value: {value.GetType()}\");","typeGuard":"bool IsPublishableValue(object? v) => v is string or FormattableString or IManifestExpressionProvider or IAzureKeyVaultSecretReference;","tryCatchPattern":"try { app.WithEnvironment(\"K\", value); } catch (NotSupportedException ex) when (ex.Message.StartsWith(\"Unsupported value type\")) { /* convert to a supported reference or string */ }","preventionTips":["Use built-in resource reference APIs (endpoints, key vault refs, parameters) instead of custom wrappers.","Don't pass resource builders or domain objects where a value is expected.","Align Aspire package versions to avoid unhandled newer reference types."],"tags":["azure","container-apps","bicep","type-mismatch"],"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"}