{"record":{"id":"77429786c9aca36e","repo":"github/copilot-sdk","slug":"unknown-messagesource-value-value-774297","errorCode":null,"errorMessage":"Unknown MessageSource value: {value}","messagePattern":"Unknown MessageSource value: (.+?)","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Types.cs","lineNumber":2178,"sourceCode":"        return new(\"agent-\" + id);\n    }\n\n    /// <inheritdoc/>\n    public override string ToString() => Value;\n\n    /// <summary>Converts message sources to and from their wire strings.</summary>\n    public sealed class Converter : JsonConverter<MessageSource>\n    {\n        /// <inheritdoc/>\n        public override MessageSource Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n        {\n            var value = GeneratedStringEnumJson.ReadValue(ref reader, typeToConvert);\n            return value switch\n            {\n                \"user\" => User,\n                \"system\" => System,\n                _ when value.StartsWith(\"agent-\", StringComparison.Ordinal) => new MessageSource(value),\n                _ => throw new JsonException($\"Unknown MessageSource value: {value}\")\n            };\n        }\n\n        /// <inheritdoc/>\n        public override void Write(Utf8JsonWriter writer, MessageSource value, JsonSerializerOptions options) =>\n            writer.WriteStringValue(value.Value);\n    }\n}\n\n/// <summary>\n/// Specifies the operation to perform on a system message section.\n/// </summary>\n[JsonConverter(typeof(JsonStringEnumConverter<SectionOverrideAction>))]\npublic enum SectionOverrideAction\n{\n    /// <summary>Replace the section content entirely.</summary>\n    [JsonStringEnumMemberName(\"replace\")]\n    Replace,","sourceCodeStart":2160,"sourceCodeEnd":2196,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/dotnet/src/Types.cs#L2160-L2196","documentation":"The MessageSource converter parses the string via GeneratedStringEnumJson.ReadValue, then maps it: \"user\" → User, \"system\" → System, anything starting with \"agent-\" → a dynamic MessageSource. Any other value throws this JsonException listing the unrecognized value.","triggerScenarios":"Deserializing JSON like `\"source\": \"assistant\"` or `\"source\": \"tool\"` — a string that is neither \"user\", \"system\", nor prefixed \"agent-\".","commonSituations":"New source kinds introduced server-side that the local SDK version does not know; typos in hand-written JSON; other SDKs emitting different source identifiers.","solutions":["Use one of the supported values: \"user\", \"system\", or an \"agent-<name>\" string.","Upgrade the SDK to a version that recognizes the new MessageSource value.","Check the API changelog for renamed source identifiers.","Catch JsonException and fall back to a raw/generic source representation if the library offers one."],"exampleFix":"// before\n{\"source\": \"assistant\"}\n// after\n{\"source\": \"agent-assistant\"} // or \"user\"/\"system\"","handlingStrategy":"try-catch","validationCode":"var s = doc.RootElement.GetProperty(\"source\").GetString();\nvar known = s == \"user\" || s == \"system\" || (s?.StartsWith(\"agent-\") ?? false);\nif (!known) throw new InvalidDataException($\"unsupported MessageSource: {s}\");","typeGuard":"static bool IsKnownMessageSource(string s) => s is \"user\" or \"system\" || s.StartsWith(\"agent-\");","tryCatchPattern":"try { msg = JsonSerializer.Deserialize<Message>(json); }\ncatch (JsonException ex) { log.LogWarning(ex, \"unknown MessageSource '{V}' — upgrade SDK or normalize value\", rawValue); }","preventionTips":["Only emit user/system/agent-* source values","Keep the SDK updated for new server-side source kinds","Normalize/whitelist values at the boundary","Monitor logs for unknown values to detect schema drift"],"tags":["json","deserialization","dotnet","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"cd8cf15dc3f9e762615790aaed0a771a0f392755","analyzedAt":"2026-09-09T18:32:31.973Z","contentChangedAt":"2026-09-09T18:32:31.973Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}