AmbiguousTimeoutException when params missed in query

Using SDK 3.3

    <dependency>
        <groupId>com.couchbase.client</groupId>
        <artifactId>java-client</artifactId>
        <version>3.3.3</version>
    </dependency>

Got an com.couchbase.client.core.error.AmbiguousTimeoutException when a parametrized n1ql was executed without passing the params. This was a bug in our application but the troubleshooting was made greatly difficult by the fact that instead of giving a parameter missing error the query timed out after the 75s n1ql timeout limit without any hint on the underlying issue.

   String query = "SELECT t.workflow.name, t.status " +
                "FROM bucket1 t " +
                "WHERE t.env == $env " +
                "AND t.createdTs >= $start " +
                "AND t.createdTs <= $end";
    List<Record> data = cluster.query(query, queryOptions()).rowsAs(Record.class);
   // We missed providing the parameters as given below
   //List<Record> data = cluster.query(query, queryOptions().parameters(param)).rowsAs(Record.class);
1 Like
 String query = "SELECT t.workflow.name, t.status " +
                "FROM bucket1 t " +
                "WHERE t.env == $env " +
                "AND t.createdTs >= $start " +
                "AND t.createdTs <= $end";
    List<Record> data = cluster.query(query, queryOptions()).rowsAs(Record.class);

I find it returns immediately with an appropriate exception. It’s difficult to troubleshoot without seeing the actual exception/stack trace. More logging is available by setting

    <logger name="com.couchbase" level="debug"/>"
	@Test void myTest(){
		String query = "SELECT t.workflow.name, t.status " +
				"FROM my_bucket t " +
				"WHERE t.env == $env " +
				"AND t.createdTs >= $start " +
				"AND t.createdTs <= $end";
		long t0 = System.currentTimeMillis();
		try {
			List<Record> data = clientFactory.getCluster() // cluster from spring data
					.query(query,
							queryOptions())
					.rowsAs(Record.class);
		} catch(Exception e){
			System.err.println(e);
			System.err.println("elapsed: "+(System.currentTimeMillis()-t0)+" milliseconds");
		}
	}
com.couchbase.client.core.error.InternalServerFailureException: Internal Couchbase Server error {"completed":true,"coreId":"0x8b0e1e0f00000002","errors":[{"code":5010,"message":"Error evaluating filter - cause: No value for named parameter $env (near line 1, column 65).","retry":false}],"httpStatus":200,"idempotent":false,"lastDispatchedFrom":"127.0.0.1:54112","lastDispatchedTo":"127.0.0.1:8093","requestId":12,"requestType":"QueryRequest","retried":0,"service":{"operationId":"e4711c10-c5a5-468e-bf44-40e026b6d743","statement":"SELECT t.workflow.name, t.status FROM my_bucket t WHERE t.env == $env AND t.createdTs >= $start AND t.createdTs <= $end","type":"query"},"timeoutMs":75000,"timings":{"dispatchMicros":2670,"totalDispatchMicros":2670,"totalMicros":3761}}
elapsed: 5 milliseconds