{"record":{"id":"091fcb3711639ea3","repo":"ThreeMammals/Ocelot","slug":"no-conversion-available-for-the-type-targettype-name","errorCode":null,"errorMessage":"No conversion available for the type: {targetType.Name}","messagePattern":"No conversion available for the type: (.+?)","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/Metadata/DownstreamRouteExtensions.cs","lineNumber":150,"sourceCode":"    /// <param name=\"numberStyle\">The current number style configuration.</param>\r\n    /// <returns>The parsed string as object of type targetType.</returns>\r\n    /// <exception cref=\"NotImplementedException\">Exception thrown if the conversion for the type target type can't be found.</exception>\r\n    private static object ConvertToNumericType(string value, Type targetType, IFormatProvider provider, NumberStyles numberStyle)\r\n    {\r\n        return targetType switch\r\n        {\r\n            { } t when t == typeof(byte) => byte.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(sbyte) => sbyte.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(short) => short.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(ushort) => ushort.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(int) => int.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(uint) => uint.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(long) => long.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(ulong) => ulong.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(float) => float.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(double) => double.Parse(value, numberStyle, provider),\r\n            { } t when t == typeof(decimal) => decimal.Parse(value, numberStyle, provider),\r\n            _ => throw new NotImplementedException($\"No conversion available for the type: {targetType.Name}\"),\r\n        };\r\n    }\r\n}\r\n","sourceCodeStart":132,"sourceCodeEnd":154,"githubUrl":"https://github.com/ThreeMammals/Ocelot/blob/d1f22d930430410bfd0233f5e9e4f92980cf7df0/src/Metadata/DownstreamRouteExtensions.cs#L132-L154","documentation":"This is the explicit failure arm of ConvertToNumericType in DownstreamRouteExtensions, a helper that parses metadata string values into concrete numeric types (byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal, ...). The switch is an exhaustive allow-list; when a caller asks ConvertTo for a targetType that is none of the supported numeric types, no conversion arm matches and the method throws NotImplementedException, as documented by the <exception> tag on the method. The input at fault is the targetType argument — e.g. a bool, char, Guid, enum, or nullable/custom type passed through the metadata conversion path — not the string value itself. Because ConvertTo is used when reading route metadata into typed values, this error surfaces during request handling or startup whenever a metadata value's declared type is outside the supported numeric set.","triggerScenarios":"Thrown at src/Metadata/DownstreamRouteExtensions.cs:150 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use only the supported numeric target types (byte, sbyte, short, ushort, int, uint, long, ulong, float, double, decimal) when declaring metadata value types.","Extend the switch expression in ConvertToNumericType with an arm for the missing targetType if the new type is legitimately needed.","If non-numeric types are required, route them to a different conversion helper (e.g. bool/string parsing) instead of ConvertToNumericType.","Validate the metadata configuration at startup so unsupported types are rejected before requests flow through the route.","Catch NotImplementedException at the ConvertTo call site and fall back to returning the raw string value, logging the unsupported type."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d1f22d930430410bfd0233f5e9e4f92980cf7df0","analyzedAt":"2026-09-12T13:50:06.067Z","contentChangedAt":"2026-09-12T13:50:06.067Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}