{"record":{"id":"526b47433dfd8ae7","repo":"t8y2/dbx","slug":"unknown-method-method-526b47","errorCode":null,"errorMessage":"Unknown method: <method>","messagePattern":"Unknown method: <method>","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java","lineNumber":1871,"sourceCode":"            case AgentProtocol.MONGO_METHOD_DROP_INDEXES -> dropIndexes(params);\n            case AgentProtocol.MONGO_METHOD_DROP_COLLECTION -> dropCollection(params);\n            case AgentProtocol.MONGO_METHOD_CLONE_COLLECTION -> cloneCollection(params);\n            case AgentProtocol.MONGO_METHOD_DROP_DATABASE -> dropDatabase(params);\n            case AgentProtocol.MONGO_METHOD_INSERT_DOCUMENT -> insertDocument(params);\n            case AgentProtocol.MONGO_METHOD_INSERT_DOCUMENTS -> insertDocuments(params);\n            case AgentProtocol.MONGO_METHOD_UPDATE_DOCUMENT -> updateDocument(params);\n            case AgentProtocol.MONGO_METHOD_UPDATE_DOCUMENTS -> updateDocuments(params);\n            case AgentProtocol.MONGO_METHOD_DELETE_DOCUMENT -> deleteDocument(params);\n            case AgentProtocol.MONGO_METHOD_DELETE_DOCUMENTS -> deleteDocuments(params);\n            case AgentProtocol.MONGO_METHOD_RUN_COMMAND -> runCommand(params);\n            case AgentProtocol.METHOD_DISCONNECT, AgentProtocol.METHOD_SHUTDOWN -> {\n                closeLegacyClient();\n                if (AgentProtocol.METHOD_SHUTDOWN.equals(method)) {\n                    System.exit(0);\n                }\n                yield Collections.singletonMap(\"ok\", true);\n            }\n            default -> throw new IllegalArgumentException(\"Unknown method: \" + method);\n        };\n    }\n\n    static AgentProtocol.HandshakeResult runtimeHandshakeResult() {\n        return AgentProtocol.mongoLegacyMultiSessionHandshakeResult();\n    }\n\n    private static MongoClient requireClient() {\n        MongoClient client = CURRENT_CLIENT.get();\n        if (client == null) {\n            client = legacyClient;\n        }\n        if (client == null) {\n            throw new IllegalStateException(\"Not connected\");\n        }\n        return client;\n    }\n","sourceCodeStart":1853,"sourceCodeEnd":1889,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java#L1853-L1889","documentation":"The agent's request dispatch switch has a `default` branch that throws IllegalArgumentException(\"Unknown method: ...\") when the incoming `method` string matches none of the supported protocol methods. This guards the agent protocol boundary: any typo'd, unsupported, or version-mismatched method name is rejected explicitly.","triggerScenarios":"Sending a request frame with `method` set to something like `mongo.query` or `listDatabases ` (trailing space) that is not in the AgentProtocol switch; using a newer client against an older agent build lacking that method.","commonSituations":"Typos in method names; case mismatches (e.g. `ping` vs `PING`); client/agent version skew where the client uses a method the agent doesn't implement; custom scripts calling internal methods.","solutions":["Check the exact method name against the AgentProtocol constants supported by this agent version.","Fix casing/typo/whitespace in the method string (names are matched exactly).","Upgrade the agent binary if the method exists only in a newer protocol version.","Add debug logging of the raw `method` value to spot invisible whitespace or encoding issues."],"exampleFix":"// before\n{\"method\": \"mongo.updateMany\"}\n// after (exact protocol method name)\n{\"method\": \"updateMany\"}","handlingStrategy":"try-catch","validationCode":"// Java: check method against a known whitelist before dispatch\nSet<String> supported = Set.of(\"connect\", \"find\", \"insert\", \"updateOne\", \"updateMany\", \"delete\", \"shutdown\");\nif (!supported.contains(method)) {\n    throw new IllegalArgumentException(\"Unsupported method: \" + method);\n}","typeGuard":null,"tryCatchPattern":"try { response = agent.dispatch(request); }\ncatch (IllegalArgumentException e) {\n  if (e.getMessage().startsWith(\"Unknown method:\")) {\n    log.error(\"Method {} not supported by agent version {}\", request.method, agentVersion);\n    // surface a client-side 'upgrade agent' error\n  } else throw e;\n}","preventionTips":["Reference method names from shared AgentProtocol constants, not literals","Keep client and agent protocol versions in lockstep (version check at handshake)","Trim and normalize method strings before dispatch"],"tags":["protocol","dispatch","unknown-method","versioning"],"backgroundTag":"unknown-method","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"}