{"record":{"id":"154511f580883be1","repo":"t8y2/dbx","slug":"mongodb-aggregate-pipeline-is-required","errorCode":null,"errorMessage":"MongoDB aggregate pipeline is required","messagePattern":"MongoDB aggregate pipeline is required","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java","lineNumber":521,"sourceCode":"        try (MongoCursor<Document> cursor = iterable.iterator()) {\n            while (documents.size() < fetchLimit && cursor.hasNext()) {\n                Document document = cursor.next();\n                documents.add(bsonToJson(document));\n                extendedDocuments.add(bsonToExtendedJson(document));\n            }\n        }\n        long total = documents.size();\n        if (documents.size() > maxRows) {\n            documents.subList(maxRows, documents.size()).clear();\n            extendedDocuments.subList(maxRows, extendedDocuments.size()).clear();\n        }\n        return documentQueryResultWithExtended(documents, extendedDocuments, total);\n    }\n\n    static List<Document> aggregatePipeline(JsonObject params) {\n        String source = stringOrNull(params, \"pipeline\");\n        if (source == null || source.isBlank()) {\n            throw new IllegalArgumentException(\"MongoDB aggregate pipeline is required\");\n        }\n        JsonElement parsed = JsonParser.parseString(source);\n        if (!parsed.isJsonArray()) {\n            throw new IllegalArgumentException(\"MongoDB aggregate pipeline must be a JSON array\");\n        }\n        List<Document> pipeline = new ArrayList<>();\n        for (JsonElement stage : parsed.getAsJsonArray()) {\n            if (!stage.isJsonObject()) {\n                throw new IllegalArgumentException(\"Each MongoDB aggregate pipeline stage must be an object\");\n            }\n            pipeline.add(Document.parse(stage.toString()));\n        }\n        return pipeline;\n    }\n\n    static Document aggregateOptions(JsonObject params) {\n        Document options = documentOrNull(params, \"options\");\n        return options == null ? new Document() : options;","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java#L503-L539","documentation":"Thrown by MongoAgent.aggregatePipeline when the 'pipeline' parameter of an aggregate operation is missing, null, or blank. The aggregation command cannot run without a pipeline definition, so the request is rejected before parsing.","triggerScenarios":"Thrown at agents/drivers/mongodb/src/main/java/com/dbx/agent/mongodb/MongoAgent.java:521 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass pipeline as a JSON array string, e.g. \"[{\\$match: {status: \\\"active\\\"}}]\"","Even for a no-filter aggregation supply at least an empty stage array or a trivial stage like [{\"$limit\": 10}]"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}