{"record":{"id":"7c5ef320f32c788e","repo":"github/copilot-sdk","slug":"unknown-messagesource-value-value","errorCode":null,"errorMessage":"Unknown MessageSource value: + value","messagePattern":"Unknown MessageSource value: \\+ value","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/rpc/MessageSource.java","lineNumber":82,"sourceCode":"     * @return the matching source, or {@code null} if value is {@code null}\n     * @throws IllegalArgumentException\n     *             if the value does not match a known message source\n     */\n    @JsonCreator\n    public static MessageSource fromValue(String value) {\n        if (value == null) {\n            return null;\n        }\n        if (USER.value.equals(value)) {\n            return USER;\n        }\n        if (SYSTEM.value.equals(value)) {\n            return SYSTEM;\n        }\n        if (value.startsWith(\"agent-\")) {\n            return new MessageSource(value);\n        }\n        throw new IllegalArgumentException(\"Unknown MessageSource value: \" + value);\n    }\n\n    @Override\n    public String toString() {\n        return value;\n    }\n\n    @Override\n    public boolean equals(Object other) {\n        return other instanceof MessageSource source && value.equals(source.value);\n    }\n\n    @Override\n    public int hashCode() {\n        return value.hashCode();\n    }\n}\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/rpc/MessageSource.java#L64-L100","documentation":"MessageSource.fromValue resolves a string to a MessageSource: it special-cases the SYSTEM value and accepts any \"agent-\"-prefixed string as a dynamic agent source. Any other value throws IllegalArgumentException. The library therefore only recognizes the system source and agent-prefixed sources.","triggerScenarios":"Calling MessageSource.fromValue with a string that is neither exactly the SYSTEM value nor starts with \"agent-\" — e.g. \"user\", \"tool\", \"Agent-1\" (wrong case), or a trailing-space value.","commonSituations":"Routing messages with hand-written source strings; protocol changes introducing new source kinds not yet in the SDK; user input reaching message construction without normalization.","solutions":["Check the exact SYSTEM constant spelling and the \"agent-\" prefix (lowercase, with hyphen) against your value.","Trim/normalize the input string before calling fromValue.","If you need a new source kind, upgrade the SDK or construct MessageSource via the supported public API instead of fromValue.","Catch IllegalArgumentException and map unknown sources to a default or reject them upstream with a clear validation error."],"exampleFix":"// before\nMessageSource src = MessageSource.fromValue(userInput); // \"user\" -> throws\n\n// after\nString v = userInput.trim().toLowerCase(Locale.ROOT);\nMessageSource src = (v.startsWith(\"agent-\") || v.equals(\"system\"))\n        ? MessageSource.fromValue(v)\n        : MessageSource.SYSTEM;","handlingStrategy":"validation","validationCode":"static boolean isKnownMessageSource(String v) {\n    String t = v == null ? \"\" : v.trim();\n    return t.equals(\"system\") || t.startsWith(\"agent-\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    source = MessageSource.fromValue(value);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Unknown message source '\" + value + \"', using SYSTEM\");\n    source = MessageSource.SYSTEM;\n}","preventionTips":["Trim and lowercase source strings before resolving","Restrict source construction to a single factory that enforces the SYSTEM/agent- convention","Handle unknown sources at protocol boundary with explicit rejection rather than deep in routing","Keep the SDK updated for new source kinds introduced by the protocol"],"tags":["java","enum","rpc","validation"],"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"}