Support Questions
Find answers, ask questions, and share your expertise

How to verify required parameters is valid in case MongoDB processor

@MattWho  @TimothySpann  @Shu_ashu 


Currently, I am trying to fetch data from the MongoDB with help of the GetMongo processors which is working fine but in case if any of the required parameters are not valid (i.e. collection name, database name, and so on) it should throw an error which is not happening it is keep on running. In the case of SQL processor (i.e. ExecuteSQL, QueryDatabaseTable, and so on) if any of the required parameters is invalid it throws an error (For example, the password is invalid, table/view does not exist, and so on) expecting the same kind of behavior in case of MongoDB processor. 

Is there any way to validate the required parameters.


Super Guru

Maybe a bug or oversite.   GetMongo is a community processor, post or update a JIRA

Thanks, @TimothySpann for the quick reply. Even I have tried the same scenario with the RunMongoAggregation processor it is also keeping running in case of invalid credentials instead of throwing an error.



Super Guru
Fork the processor

Super Guru


Hi @vineet_harkut ,

To check if the required parameters are valid in MongoDB processor, what I would do is

Suppose, there is a query like {"key":"someValue","name":"someOtherValue"}.

And "someValue" and "someOtherValue" are values inside the attributes of the incoming flowFile with attribute-names "key" and "name" respectively. Hence, the resulting query in the GetMongo processor will be {"key":"${key}","name":"${name}"}.

Before using the GetMongo processor, I would use RouteOnAttribute processor to check if the input to the query is a valid one.
Screenshot from 2020-09-30 00-50-50.png

Screenshot from 2020-09-30 00-52-35.png

If the input is correct, I will make a query to the GetMongo processor. If the document for the query is not found, the GetMongo processor will return empty document (empty string) as content in the flowfile only when Send Empty Result is set to true inside the GetMongo processor.
Screenshot from 2020-09-30 01-13-59.png

Later, when I use EvaluateJsonPath processor, the flowfile will be routed to "failure" when the flowfile is empty, as empty string is not a valid JSON or to "matched" if the match for the given jsonPath is found.
This will put the same content inside the flowfile as $ corresponds to entire JSON object that we are getting from the input flowfIle.

Now, you can add the remaining logic.

; ;