{"record":{"id":"43ae392912299818","repo":"t8y2/dbx","slug":"dropindex-does-not-accept-use-dropindexes-o","errorCode":null,"errorMessage":"dropIndex does not accept \"*\"; use dropIndexes() or dropIndexes(\"*\") instead","messagePattern":"dropIndex does not accept \"\\*\"; use dropIndexes\\(\\) or dropIndexes\\(\"\\*\"\\) instead","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java","lineNumber":1379,"sourceCode":"        return Collections.singletonMap(\"ok\", true);\n    }\n\n    static Object parseDropIndexesValue(String indexesJson, boolean single) {\n        if (indexesJson == null || indexesJson.isBlank()) {\n            if (single) {\n                throw new IllegalArgumentException(\"dropIndex requires a string index name or JSON document\");\n            }\n            return \"*\";\n        }\n\n        JsonElement value = JsonParser.parseString(indexesJson);\n        if (value.isJsonPrimitive() && value.getAsJsonPrimitive().isString()) {\n            String name = value.getAsString();\n            if (name.isBlank()) {\n                throw new IllegalArgumentException(\"Index name is required\");\n            }\n            if (single && \"*\".equals(name)) {\n                throw new IllegalArgumentException(\"dropIndex does not accept \\\"*\\\"; use dropIndexes() or dropIndexes(\\\"*\\\") instead\");\n            }\n            if (DEFAULT_ID_INDEX_NAME.equals(name)) {\n                throw new IllegalArgumentException(\"The default MongoDB _id_ index cannot be dropped\");\n            }\n            return name;\n        }\n        if (value.isJsonObject()) {\n            JsonObject object = value.getAsJsonObject();\n            if (object.size() == 0) {\n                throw new IllegalArgumentException(\"Index specification is required\");\n            }\n            Document specification = Document.parse(indexesJson);\n            if (isDefaultIdIndexSpecification(specification)) {\n                throw new IllegalArgumentException(\"The default MongoDB _id_ index cannot be dropped\");\n            }\n            return specification;\n        }\n        if (value.isJsonArray()) {","sourceCodeStart":1361,"sourceCodeEnd":1397,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java#L1361-L1397","documentation":"The wildcard \"*\" means 'drop all indexes' and is supported only by dropIndexes (single=false). dropIndex intentionally rejects \"*\" to prevent accidental mass index deletion through the single-index API, directing users to the batch action.","triggerScenarios":"Calling dropIndex with indexes=\"*\" (or JSON string \"\\\"*\\\"\") intending to clear all indexes.","commonSituations":"Migrating a schema and wanting a clean index slate; copying dropIndexes(\"*\") examples but invoking the wrong action name.","solutions":["Use dropIndexes with \"*\" to drop all secondary indexes","Or call dropIndex once per specific index name you want removed","Remember the _id_ index can never be dropped either way"],"exampleFix":"// before\nagent.execute(\"dropIndex\", Map.of(\"indexes\", \"*\"));\n// after\nagent.execute(\"dropIndexes\", Map.of(\"indexes\", \"*\")); // batch drop of all secondary indexes","handlingStrategy":"validation","validationCode":"if (\"*\".equals(indexName) || \"\\\"*\\\"\".equals(indexesJson)) {\n    // route to batch API instead\n    agent.execute(\"dropIndexes\", Map.of(\"indexes\", \"*\"));\n    return;\n}","typeGuard":"boolean isWildcardIndex(String name) {\n    return \"*\".equals(name);\n}","tryCatchPattern":"try {\n    agent.execute(\"dropIndex\", params);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"does not accept\")) {\n        agent.execute(\"dropIndexes\", Map.of(\"indexes\", \"*\"));\n    } else { throw e; }\n}","preventionTips":["Map wildcard intents to dropIndexes at the call site","Never pass '*' to single-index APIs","Review any code path where the index name comes from user input"],"tags":["validation","mongodb","indexes","api-misuse"],"backgroundTag":"invalid-argument-value","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}