{"record":{"id":"dee97379a4125abd","repo":"t8y2/dbx","slug":"mongodb-explain-verbosity-must-be-queryplanner-ex","errorCode":null,"errorMessage":"MongoDB explain verbosity must be queryPlanner, executionStats, or allPlansExecution","messagePattern":"MongoDB explain verbosity must be queryPlanner, executionStats, or allPlansExecution","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java","lineNumber":717,"sourceCode":"            find.append(\"collation\", collation);\n        }\n\n        long skip = params.has(\"skip\") ? params.get(\"skip\").getAsLong() : 0;\n        if (skip > 0) {\n            find.append(\"skip\", skip);\n        }\n        long limit = params.has(\"limit\") ? params.get(\"limit\").getAsLong() : 0;\n        if (limit > 0) {\n            find.append(\"limit\", limit);\n        }\n        return new Document(\"explain\", find)\n            .append(\"verbosity\", findExplainVerbosity(params));\n    }\n\n    private static String findExplainVerbosity(JsonObject params) {\n        String verbosity = defaultString(stringOrNull(params, \"verbosity\"), \"queryPlanner\");\n        if (!Set.of(\"queryPlanner\", \"executionStats\", \"allPlansExecution\").contains(verbosity)) {\n            throw new IllegalArgumentException(\n                \"MongoDB explain verbosity must be queryPlanner, executionStats, or allPlansExecution\");\n        }\n        return verbosity;\n    }\n\n    private static Object findOne(JsonObject params) {\n        MongoClient c = requireClient();\n        String database = params.get(\"database\").getAsString();\n        String collection = params.get(\"collection\").getAsString();\n        Document filter = documentOrNull(params, \"filter\");\n        Document projection = documentOrNull(params, \"projection\");\n        Document options = documentOrNull(params, \"options\");\n        Document sort = null;\n\n        if (options != null) {\n            for (String key : options.keySet()) {\n                if (!\"sort\".equals(key)) {\n                    throw new IllegalArgumentException(\"Unsupported findOne option: \" + key);","sourceCodeStart":699,"sourceCodeEnd":735,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java#L699-L735","documentation":"findExplainVerbosity validates the optional 'verbosity' parameter of the find explain command. It must be one of MongoDB's three explain modes: queryPlanner, executionStats, or allPlansExecution. Any other string throws this error; when omitted it defaults to queryPlanner.","triggerScenarios":"Calling the find-explain operation with verbosity set to a misspelled or unsupported value like \"verbose\", \"allPlans\", \"QUERYPLANNER\" (case-sensitive), or an empty string that is not null.","commonSituations":"Typos in verbosity values; assuming case-insensitivity; copying verbosity strings from other drivers or from the aggregate explain API which uses different wording; old config using deprecated modes.","solutions":["Use exactly one of: queryPlanner, executionStats, allPlansExecution (lowercase)","Omit verbosity to get the default queryPlanner","Check spelling and case of the value","Map legacy verbosity names to the supported set before calling"],"exampleFix":"// before\n{\"collection\":\"users\",\"filter\":{},\"verbosity\":\"allPlans\"}\n// after\n{\"collection\":\"users\",\"filter\":{},\"verbosity\":\"allPlansExecution\"}","handlingStrategy":"validation","validationCode":"const VERBOSITIES = new Set(['queryPlanner','executionStats','allPlansExecution']);\nif (verbosity != null && !VERBOSITIES.has(verbosity)) throw new Error('bad verbosity: ' + verbosity);","typeGuard":"function isExplainVerbosity(v) {\n  return v == null || ['queryPlanner','executionStats','allPlansExecution'].includes(v);\n}","tryCatchPattern":"try {\n  result = agent.findExplain(params);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"MongoDB explain verbosity\")) {\n    params.verbosity = 'queryPlanner';\n    result = agent.findExplain(params);\n  } else throw e;\n}","preventionTips":["Copy verbosity strings exactly: queryPlanner, executionStats, allPlansExecution","Remember the check is case-sensitive","Normalize legacy verbosity names before calling","Omit the field to use the safe default"],"tags":["mongodb","explain","validation","enum"],"backgroundTag":"invalid-enum-value","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"}