n1ql - Unexpected end of input


I have a n1ql command that I run, and about half the time it gives me an error, and the other half it gives me the expected results. Nothing about this statement changes, and I find that odd. The data is also consistent from run to run. Perhaps, someone can tell me why it’s doing that, and if maybe I have the wrong statement.

SELECT p FROM Page_Bucket p JOIN Company_Bucket c ON KEYS p.companyId WHERE ARRAY_CONTAINS(c.aryDomains, “test”);

the error is:


SyntaxError: Unexpected end of input
at parse (native)



Are you running this from the cbq command line shell, or from an SDK? If SDK, please indicate which.



From an SDK through nodejs.


Can you post some code to reproduce?


Hopefully, you don’t need all of it, but the function is pretty simple. The m_n1q1Query is the N1qlQuery in the couchbase.js. The m_oPrimaryBucket is return of the openBucket on a new Cluster from the couchbase.js.

var l_strQuery;
l_strQuery = "SELECT p ";
l_strQuery += " FROM Page_Bucket p ";
l_strQuery += " JOIN Company_Bucket c ON KEYS p.companyId “;
l_strQuery += " WHERE ARRAY_CONTAINS(c.aryDomains, “” + p_strDomain + “”)”;
l_strQuery += “;”;

var l_oQuery = this.m_n1qlQuery.fromString(l_strQuery);
this.m_oPrimaryBucket.query(l_oQuery, pf_handleResponse);

BTW, I simplified this down a step and found I get the same error. The lesser N1QL is:

SELECT p FROM Page_Bucket p JOIN Company_Bucket c ON KEYS p.companyId;



thank you, can you also post the full error output? I think at this point it is unclear whether the error comes from nodejs or the n1ql query engine. Thank you!


Hey @dsayko,

Could you also provide us versions of the Node.js SDK and Couchbase Server (and maybe cbq) that you are using?

Cheers, Brett


@brett19 - Today, we are using 4.0.0-4047 DEV Edition (build-4047) for the server. I don’t know what version I was using yesterday. The sdk is 2.0.8.
@daschl - The unfortunate thing is, that was the whole message.

We found that if we removed the bucket passwords, we no longer had any errors. It works consistently. There’s probably a good chance that n1ql doesn’t yet work correctly when there are passwords. We hope that we can eventually add back in the passwords to the system, but for now, we’re going to run without them.


Hey @dsayko,

Could you try to use the Node.js SDK v2.1.1 and see if that resolves your issues? Otherwise I will open a ticket and look into this.

Cheers, Brett


As soon as I can, I will. I’m just way behind, and don’t have the time right now to try that. I have something working which is the removing passwords. A terrible solution, but a temporary one anyway.