{"record":{"id":"922def5171b62584","repo":"jd-opensource/joyagent-jdgenie","slug":"command-is-required","errorCode":null,"errorMessage":"Command is required","messagePattern":"Command is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"genie-backend/src/main/java/com/jd/genie/agent/tool/common/PlanningTool.java","lineNumber":129,"sourceCode":"\n    private Map<String, Object> getStepNotesProperty() {\n        Map<String, Object> stepNotes = new HashMap<>();\n        stepNotes.put(\"type\", \"string\");\n        stepNotes.put(\"description\", \"Additional notes for a step. Optional for mark_step command.\");\n        return stepNotes;\n    }\n\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","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/jd-opensource/joyagent-jdgenie/blob/2417e0b8b636d941ad5fb14c59b20dddfef5375d/genie-backend/src/main/java/com/jd/genie/agent/tool/common/PlanningTool.java#L111-L147","documentation":"Validation guard at the top of PlanningTool.execute: the input map is cast from JSON and the 'command' parameter selects which planning operation (create_plan, mark_step, etc.) to run. Because 'command' is the mandatory discriminator, executing without it is unrecoverable, so execute throws IllegalArgumentException before dispatching. Fires when a caller/LLM omits the command field from the planning tool arguments.","triggerScenarios":"Calling execute with a Map that lacks the command key, has command: null, or command: \"\".","commonSituations":"LLM emitted tool arguments without the command field, key casing mismatch (e.g. \"Command\"), or arguments built programmatically and command omitted.","solutions":["Always include a non-empty command key in the tool arguments","Validate required keys before calling execute","Check the LLM tool schema/JSON emitted for the planning tool"],"exampleFix":"// before\nplanningTool.execute(Map.of(\"title\", \"t\", \"steps\", List.of(\"s\")));\n// after\nplanningTool.execute(Map.of(\"command\", \"create\", \"title\", \"t\", \"steps\", List.of(\"s\")));","handlingStrategy":"validation","validationCode":"Object cmd = params.get(\"command\");\nif (cmd == null || cmd.toString().isEmpty()) { throw new IllegalArgumentException(\"command required\"); }","typeGuard":null,"tryCatchPattern":"try {\n    return planningTool.execute(params);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Command is required\")) { /* fix args */ }\n    throw e;\n}","preventionTips":["Mark command required in the tool JSON schema","Validate required keys before invocation","Check LLM-emitted arguments for missing fields"],"tags":["java","tool","missing-argument"],"backgroundTag":"missing-required-argument","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"}