{"record":{"id":"83ea82babb452845","repo":"t8y2/dbx","slug":"is-required","errorCode":null,"errorMessage":" is required.","messagePattern":" is required\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java","lineNumber":4499,"sourceCode":"                node.putNull(field);\n            }\n            return;\n        }\n        node.put(field, value);\n    }\n\n    private static void putNullableInt(ObjectNode node, String field, Object value) {\n        if (value instanceof Number number) {\n            node.put(field, number.intValue());\n        } else {\n            node.putNull(field);\n        }\n    }\n\n    private static String requireText(JsonNode node, String field) {\n        String value = optionalText(node, field);\n        if (value == null) {\n            throw new IllegalArgumentException(field + \" is required.\");\n        }\n        return value;\n    }\n\n    private static String optionalText(JsonNode node, String field) {\n        JsonNode value = node.path(field);\n        if (value.isMissingNode() || value.isNull()) {\n            return null;\n        }\n        String text = value.asText(\"\").trim();\n        return text.isEmpty() ? null : text;\n    }\n\n    private static List<String> optionalStringList(JsonNode node, String field) {\n        JsonNode value = node.path(field);\n        if (value.isMissingNode() || value.isNull()) {\n            return null;\n        }","sourceCodeStart":4481,"sourceCodeEnd":4517,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java#L4481-L4517","documentation":"requireText is a request-validation helper: it reads a text field from the incoming RPC JSON node and throws IllegalArgumentException(\"<field> is required.\") when the field is absent, null, or blank. The odd trailing-space message comes from the concatenation field + \" is required.\", so the actual missing field name prefixes the message. It is a fail-fast guard ensuring mandatory RPC parameters are present before any work is done.","triggerScenarios":"Calling any plugin RPC (query, browse, object-source, etc.) without a mandatory field such as \"connection\", \"sql\", \"name\", or \"objectType\" in the request JSON.","commonSituations":"Client omits optional-looking fields the server treats as mandatory; JSON key casing mismatch (\"Database\" vs \"database\"); empty string sent instead of a real value; API contract drift between client and plugin versions.","solutions":["Include the field named in the message (everything before \" is required.\") in the request JSON","Check exact key casing against the plugin's RPC schema/docs","Send a non-empty string, not \"\" or null","Update the client SDK to match the plugin's expected request shape"],"exampleFix":"// before\n{ \"sql\": \"SELECT 1\" } // -> IllegalArgumentException(\"connection is required.\")\n// after\n{ \"connection\": { \"url\": \"jdbc:...\" }, \"sql\": \"SELECT 1\" }","handlingStrategy":"validation","validationCode":"static void requireField(Map<String,Object> req, String field) {\n    Object v = req.get(field);\n    if (v == null || (v instanceof String s && s.isBlank())) {\n        throw new IllegalArgumentException(field + \" is required.\");\n    }\n}\nrequireField(request, \"connection\"); requireField(request, \"sql\");","typeGuard":"static boolean hasTextField(JsonNode node, String field) {\n    return node.hasNonNull(field) && node.get(field).isTextual() && !node.get(field).asText().isBlank();\n}","tryCatchPattern":"try {\n    return rpc.call(request);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().endsWith(\" is required.\")) {\n        String missing = e.getMessage().replace(\" is required.\", \"\");\n        throw new BadRequestException(\"Missing request field: \" + missing);\n    }\n    throw e;\n}","preventionTips":["Validate mandatory fields (connection, sql, name) before every RPC","Use exact key casing from the plugin's RPC schema","Never send empty strings for required text fields","Keep client SDK and plugin versions aligned to avoid contract drift"],"tags":["validation","missing-field","jdbc"],"backgroundTag":"missing-required-field","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}