{"record":{"id":"a1cd643d3f999555","repo":"elsa-workflows/elsa-core","slug":"invalid-target-type","errorCode":null,"errorMessage":"Invalid target type.","messagePattern":"Invalid target type\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/clients/Elsa.Api.Client/Extensions/ObjectConverter.cs","lineNumber":226,"sourceCode":"    /// <returns>The converted value.</returns>\n    /// <exception cref=\"ArgumentException\">Thrown if <paramref name=\"value\"/> is not of type <see cref=\"DateTime\"/> or <see cref=\"DateTimeOffset\"/>.</exception>\n    private static object ConvertAnyDateType(object value, Type targetType)\n    {\n        return targetType switch\n        {\n            { } t when t == typeof(DateTime) => value switch\n            {\n                DateTime dateTime => dateTime,\n                DateTimeOffset dateTimeOffset => dateTimeOffset.DateTime,\n                _ => throw new ArgumentException(\"Invalid value type.\")\n            },\n            { } t when t == typeof(DateTimeOffset) => value switch\n            {\n                DateTime dateTime => new DateTimeOffset(dateTime),\n                DateTimeOffset dateTimeOffset => dateTimeOffset,\n                _ => throw new ArgumentException(\"Invalid value type.\")\n            },\n            _ => throw new ArgumentException(\"Invalid target type.\")\n        };\n    }\n}","sourceCodeStart":208,"sourceCodeEnd":229,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/clients/Elsa.Api.Client/Extensions/ObjectConverter.cs#L208-L229","documentation":"ObjectConverter.ConvertAnyDateType throws ArgumentException('Invalid target type.') when called with a target type other than DateTime or DateTimeOffset. This is an internal contract violation rather than a bad input value.","triggerScenarios":"ConvertTo<T> where T's underlying type is neither DateTime nor DateTimeOffset but the code path routed into the date conversion helper (e.g. Nullable<DateTime>-adjacent types handled upstream failing to strip, or new date-like types added without updating the switch).","commonSituations":"Version upgrades where a caller relies on date-like conversion for a new type; library-internal routing bugs.","solutions":["Use ConvertTo<DateTime> or ConvertTo<DateTimeOffset> only","Check library version for routing fixes; upgrade Elsa.Api.Client","If custom types are needed, convert manually before calling"],"exampleFix":"// before\nvar d = ObjectConverter.ConvertTo<DateOnly>(value);\n// after\nvar d = DateOnly.FromDateTime(ObjectConverter.ConvertTo<DateTime>(value));","handlingStrategy":"validation","validationCode":"if (typeof(T) is not (DateTime or DateTimeOffset)) throw new NotSupportedException($\"{typeof(T)} is not a date type\");","typeGuard":null,"tryCatchPattern":"try { d = ObjectConverter.ConvertTo<DateTime>(v); } catch (ArgumentException) { /* unsupported target */ }","preventionTips":["Only call ConvertTo with DateTime/DateTimeOffset for date conversions","Convert DateOnly/TimeOnly manually via DateTime","Upgrade the client package if a new date-like type is needed"],"tags":["dotnet","datetime","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}