{"record":{"id":"c573fbd960a46266","repo":"github/copilot-sdk","slug":"fieldname-must-not-be-null-or-blank","errorCode":null,"errorMessage":"<fieldName> must not be null or blank","messagePattern":"<fieldName> must not be null or blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"java/sdk/src/main/java/com/github/copilot/tool/Param.java","lineNumber":237,"sourceCode":"    }\n\n    @Override\n    public int hashCode() {\n        return Objects.hash(type, name, description, required, defaultValue, schema);\n    }\n\n    @Override\n    public String toString() {\n        return \"Param[name=\" + name + \", type=\" + type.getSimpleName() + \", required=\" + required + \"]\";\n    }\n\n    // ------------------------------------------------------------------\n    // Internal validation helpers\n    // ------------------------------------------------------------------\n\n    private static String requireNonBlank(String value, String fieldName) {\n        if (value == null || value.isBlank()) {\n            throw new IllegalArgumentException(fieldName + \" must not be null or blank\");\n        }\n        return value;\n    }\n\n    @SuppressWarnings({\"rawtypes\", \"unchecked\"})\n    private static <T> void validateDefaultValue(Class<T> type, String defaultValue) {\n        if (defaultValue == null || defaultValue.isEmpty()) {\n            return;\n        }\n\n        try {\n            if (type == String.class) {\n                return;\n            }\n            if (type == Integer.class || type == int.class) {\n                Integer.parseInt(defaultValue);\n                return;\n            }","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/github/copilot-sdk/blob/cd8cf15dc3f9e762615790aaed0a771a0f392755/java/sdk/src/main/java/com/github/copilot/tool/Param.java#L219-L255","documentation":"Param's static requireNonBlank helper rejects null or isBlank() strings for mandatory text fields (name, description, etc.), throwing IllegalArgumentException with '<fieldName> must not be null or blank'. The message embeds the field name so the offending parameter is identified. It runs in the Param constructor, so failure happens at tool-declaration time, not call time.","triggerScenarios":"new Param(null, \"desc\", ...) — name null; new Param(\"\", \"desc\", ...) — name blank; same for description or any field routed through requireNonBlank (values like \"   \" count as blank).","commonSituations":"Programmatically generated parameter lists where a name comes from an empty map entry or missing config; refactors that pass description strings through a formatter returning empty output.","solutions":["Provide a non-blank value for the named field before constructing the Param.","Sanitize generated values: trim and reject blanks upstream of Param construction.","Catch IllegalArgumentException at registration time to fail fast with the field name in the log."],"exampleFix":"// before\nnew Param(config.get(\"name\"), \"desc\", Type.STRING, null, false, null); // name may be null\n// after\nString name = Objects.requireNonNullElse(config.get(\"name\"), \"unnamed\").trim();\nif (name.isEmpty()) throw new ConfigurationException(\"param name missing\");\nnew Param(name, \"desc\", Type.STRING, null, false, null);","handlingStrategy":"validation","validationCode":"static String requireText(String v, String field) {\n    if (v == null || v.isBlank()) throw new IllegalArgumentException(field + \" is required\");\n    return v.trim();\n}\n// usage: new Param(requireText(name, \"name\"), requireText(desc, \"description\"), ...)","typeGuard":"static boolean nonBlank(String s) { return s != null && !s.isBlank(); }","tryCatchPattern":"try {\n    params.add(new Param(name, desc, type, def, req, schema));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().endsWith(\"must not be null or blank\")) {\n        throw new ToolDefinitionException(\"Bad parameter definition: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Validate names/descriptions at the config-loading boundary, before Param construction.","Trim generated strings and reject whitespace-only values.","Construct all Params in tests at CI time to fail fast on blank fields."],"tags":["validation","null","tool-parameters","empty-string"],"backgroundTag":"empty-required-field","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"}