{"record":{"id":"4af05b3b2206c604","repo":"jd-opensource/joyagent-jdgenie","slug":"unknown-command-command","errorCode":null,"errorMessage":"Unknown command: \" + command","messagePattern":"Unknown command: \" \\+ command","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/agent/tool/common/PlanningTool.java","lineNumber":136,"sourceCode":"\n    @Override\n    public Object execute(Object input) {\n        if (!(input instanceof Map)) {\n            throw new IllegalArgumentException(\"Input must be a Map\");\n        }\n\n        Map<String, Object> params = (Map<String, Object>) input;\n        String command = (String) params.get(\"command\");\n\n        if (command == null || command.isEmpty()) {\n            throw new IllegalArgumentException(\"Command is required\");\n        }\n\n        Function<Map<String, Object>, String> handler = commandHandlers.get(command);\n        if (handler != null) {\n            return handler.apply(params);\n        } else {\n            throw new IllegalArgumentException(\"Unknown command: \" + command);\n        }\n    }\n\n    private String createPlan(Map<String, Object> params) {\n        String title = (String) params.get(\"title\");\n        List<String> steps = (List<String>) params.get(\"steps\");\n\n        if (title == null || steps == null) {\n            throw new IllegalArgumentException(\"title, and steps are required for create command\");\n        }\n\n        if (plan != null) {\n            throw new IllegalStateException(\"A plan already exists. Delete the current plan first.\");\n        }\n\n        plan = Plan.create(title, steps);\n        return \"我已创建plan\";\n    }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/agent/tool/common/PlanningTool.java#L118-L154","documentation":"PlanningTool.execute looks up a handler in commandHandlers and throws IllegalArgumentException when the provided command has no registered handler. Supported commands are only those registered in the tool's handler map (e.g. create/delete/update).","triggerScenarios":"Calling execute with command set to a value not in the handler map, e.g. \"remove\" instead of \"delete\", or a hallucinated command from the LLM.","commonSituations":"LLM inventing a command name not in the tool spec, renaming commands across versions, or typos in prompt/configured tool schemas.","solutions":["Use only commands registered in commandHandlers (check the tool source/schema)","Validate the command against the known set before calling execute","Constrain the LLM tool schema to enumerate allowed commands"],"exampleFix":"// before\nplanningTool.execute(Map.of(\"command\", \"remove\"));\n// after\nplanningTool.execute(Map.of(\"command\", \"delete\"));","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"create\",\"delete\",\"update\");\nif (!allowed.contains(command)) { throw new IllegalArgumentException(\"unknown command: \" + command); }","typeGuard":null,"tryCatchPattern":"try {\n    return planningTool.execute(params);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unknown command\")) { /* map or reject command */ }\n    throw e;\n}","preventionTips":["Enumerate allowed commands in the LLM tool schema","Validate commands against the registered handler set","Map synonyms (remove->delete) before dispatch"],"tags":["java","tool","unknown-command"],"backgroundTag":"invalid-enum-value","analyzedSha":"2417e0b8b636d941ad5fb14c59b20dddfef5375d","analyzedAt":"2026-09-08T11:28:19.414Z","contentChangedAt":"2026-09-08T11:28:19.414Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}