{"record":{"id":"a04e89a9a3e88239","repo":"t8y2/dbx","slug":"label-are-required","errorCode":null,"errorMessage":"<label> are required","messagePattern":"<label> are required","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java","lineNumber":1063,"sourceCode":"            throw new IllegalArgumentException(\"MongoDB createUser requires a non-empty user name\");\n        }\n        if (user.containsKey(\"createUser\") || user.containsKey(\"writeConcern\")) {\n            throw new IllegalArgumentException(\"MongoDB createUser user document contains reserved command fields\");\n        }\n\n        Document command = new Document(\"createUser\", username);\n        command.putAll(user);\n        Document writeConcern = documentOrNull(params, \"write_concern_json\");\n        if (writeConcern != null) {\n            command.put(\"writeConcern\", writeConcern);\n        }\n        return command;\n    }\n\n    private static Document requiredDocument(JsonObject params, String key, String label) {\n        Document document = documentOrNull(params, key);\n        if (document == null) {\n            throw new IllegalArgumentException(label + \" are required\");\n        }\n        return document;\n    }\n\n    static String defaultIndexName(Document keys) {\n        List<String> parts = new ArrayList<>();\n        for (Map.Entry<String, Object> entry : keys.entrySet()) {\n            parts.add(entry.getKey() + \"_\" + defaultIndexNameValue(entry.getValue()));\n        }\n        return String.join(\"_\", parts);\n    }\n\n    private static String defaultIndexNameValue(Object value) {\n        if (value instanceof Double number && Double.isFinite(number)) {\n            // The Rust driver's BSON formatter omits a fractional suffix for\n            // whole doubles (for example, 1.0 becomes 1). Keep unnamed index\n            // names identical on Native and Legacy connections.\n            return BigDecimal.valueOf(number).stripTrailingZeros().toPlainString();","sourceCodeStart":1045,"sourceCodeEnd":1081,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java#L1045-L1081","documentation":"requiredDocument is a generic helper: it fetches a JSON document parameter and throws IllegalArgumentException(\"<label> are required\") when the parameter is absent or null. The message template uses the caller-supplied label, e.g. \"Index keys are required\" or \"User document are required\". It signals a missing required document-typed parameter for the tool being invoked.","triggerScenarios":"Calling any tool that needs a document parameter (e.g. createIndex without keys_json, createUser without user_json) while that key is missing or explicitly null in params.","commonSituations":"LLM/tool invocations omitting an argument; typos in the parameter name (keys vs keys_json); serialization dropping null/empty fields; building requests dynamically where the document is only set conditionally.","solutions":["Add the missing parameter named in your call (per the tool's schema), e.g. keys_json for createIndex or user_json for createUser.","Check spelling of the parameter key — requiredDocument returns null for any unknown key.","Ensure your request builder always populates the document before invoking the tool, e.g. Objects.requireNonNull(map, \"keys_json\")."],"exampleFix":"// before\n{\"database\": \"app\", \"collection\": \"users\"}  // createIndex, no keys_json\n// after\n{\"database\": \"app\", \"collection\": \"users\", \"keys_json\": {\"email\": 1}}","handlingStrategy":"validation","validationCode":"function requireDoc(params, key) {\n  if (params == null || params[key] == null) {\n    throw new Error(key + \" is required (must be a non-null JSON object)\");\n  }\n  return params[key];\n}\n// usage: requireDoc(params, \"keys_json\"); requireDoc(params, \"user_json\");","typeGuard":"function isPresentDocument(params, key) {\n  return params != null && params[key] != null && typeof params[key] === \"object\";\n}","tryCatchPattern":"try {\n  await agent.toolCall(params);\n} catch (e) {\n  if (/are required$/.test(String(e.message))) {\n    const key = String(e.message).split(\" \")[0]; // e.g. \"Index\", \"User\"\n    console.error(\"Missing required document parameter for \" + key + \"; check the tool schema for the exact key name\");\n  } else throw e;\n}","preventionTips":["Consult each tool's parameter schema before invoking and populate every required *_json key.","Watch for typos: the agent looks up exact keys like keys_json, user_json, options_json.","Build request objects through a helper that asserts required documents are present."],"tags":["mongodb","validation","missing-parameter","generic"],"backgroundTag":"missing-required-parameter","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"}