{"record":{"id":"d21ec07420da5eeb","repo":"github/copilot-sdk","slug":"unknown-agentmode-value-value","errorCode":null,"errorMessage":"Unknown AgentMode value: + value","messagePattern":"Unknown AgentMode value: \\+ value","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/rpc/AgentMode.java","lineNumber":70,"sourceCode":"     *\n     * @param value\n     *            the JSON string value\n     * @return the matching {@code AgentMode}, or {@code null} if value is\n     *         {@code null}\n     * @throws IllegalArgumentException\n     *             if the value does not match any known agent mode\n     */\n    @JsonCreator\n    public static AgentMode fromValue(String value) {\n        if (value == null) {\n            return null;\n        }\n        for (AgentMode mode : values()) {\n            if (mode.value.equals(value)) {\n                return mode;\n            }\n        }\n        throw new IllegalArgumentException(\"Unknown AgentMode value: \" + value);\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":73,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/rpc/AgentMode.java#L52-L73","documentation":"AgentMode.fromValue maps a protocol string (e.g. \"ask\", \"agent\", \"edit\") to its AgentMode enum constant. If no constant's value equals the input, it throws IllegalArgumentException with the offending value. This guards against unknown or mistyped agent mode strings arriving from config or RPC payloads.","triggerScenarios":"Calling AgentMode.fromValue with a string that matches no enum constant — typos, wrong casing (\"Agent\" vs \"agent\"), or a mode introduced in a newer protocol version than the SDK supports.","commonSituations":"User-supplied agent mode from config/CLI passed straight through; a server emitting a new mode value after a protocol update; older SDK version receiving newer payloads.","solutions":["Log the exact value and compare against AgentMode.values() to see the accepted set.","Fix the typo/case to match one of the enum's documented values.","Upgrade the SDK to a version that supports the new AgentMode value.","If the value is user input, validate it against the enum's allowed values before calling fromValue, or catch IllegalArgumentException and fall back to a default mode."],"exampleFix":"// before\nAgentMode mode = AgentMode.fromValue(config.getString(\"mode\"));\n\n// after\nString v = config.getString(\"mode\", \"ask\");\nAgentMode mode;\ntry {\n    mode = AgentMode.fromValue(v);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Unknown agent mode '\" + v + \"', defaulting to ask\");\n    mode = AgentMode.ASK;\n}","handlingStrategy":"validation","validationCode":"static boolean isKnownAgentMode(String v) {\n    for (AgentMode m : AgentMode.values()) {\n        if (m.name().equalsIgnoreCase(v)) return true;\n    }\n    return false;\n}","typeGuard":null,"tryCatchPattern":"try {\n    mode = AgentMode.fromValue(value);\n} catch (IllegalArgumentException e) {\n    logger.warn(\"Unknown AgentMode '\" + value + \"'\");\n    mode = AgentMode.ASK; // documented default\n}","preventionTips":["Validate agent mode strings against the enum at config load time, not deep in RPC handling","Normalize casing/whitespace before calling fromValue","Keep SDK versions in sync with the server protocol","Write a test that round-trips every AgentMode through fromValue/toString"],"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"}