Ottoman v2 .find error


Just to inform, Using example, I receive an error: Error: path exists

Oh nvm, i found the solution. I didn’t create index on the bucket.

Can we change the error to a more meaningful message?


What was the error you were getting ? Yes we can change it to be a meaningful error message.

While trying to do this

try {
        const filter = { lastName: 'Tom' };
        const options = { consistency: ottoman.SearchConsistency.LOCAL };
        const result = await User.find(filter, options)
        console.log('Query Result: ', result.rows)
      } catch (err) {
        throw err;

The error thrown is: Error: path exists

Thanks much for your feedback, keep playing with this new toy, your feedback helps !

@Clive one more thing as a general recommendation where Indexes gets created by default.
In your startup call ensureIndexes, something like this

.then(() => {
.catch((e) => console.log(e))

I have reported this to the team as well, this should be fixed soon.

To tag along this ensureIndexes conversation, I’ve followed and added this code into my unit test and remove all indexes from couchbase server.

before(() => {
    service = new UnitTestService(options);
      .then(() => {
        console.log('All the indexes were registered');
      .catch((e) => console.log('hello: ', e));

The behavior when running my test cases output the following

(node:15224) UnhandledPromiseRejectionWarning: Error: LCB_ERR_HTTP (1053): HTTP Operation failed. Inspect status code for details
(node:15224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see (rejection id: 1)(node:15224) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I’ve notice that the #primary index is created at couchbase server. The second time i run the unit test, it output different and was caught in the before() catch exception.

hello: [Error: LCB_ERR_HTTP (1053): HTTP Operation failed. Inspect status code for details] {
code: 1053,
ctxtype: ‘query’,
first_error_code: 5000,
first_error_message: ‘GSI CreateIndex() - cause: Create index or Alter replica cannot proceed due to rebalance in progress, another concurrent create index request, network partition, node failover, indexer failure, or presence of duplicate index name.’,
statement: ‘CREATE INDEX Ottoman_scope_type ON TestBucket(_scope, _type) USING GSI WITH {“defer_build”: true}’,
client_context_id: ‘7feb395c31c281f8’,
parameters: ‘’,
http_response_code: 500,
http_response_body: ‘’

Couchbase server show another index created called Ottoman_scope_type and the status show created and stated the following:

Index definition has been saved. User Build Index to build the index. It is NOT serving scan requests yet.

Further this point, all the test ran gave the following log

All the indexes were registered
All the indexes were registered

Just wondering why is there a difference in output at the start of the test and what happen when ensureIndexes() is called? Also to add on, why are there 2 response for All the indexes were registered ?

PS: Let me know if want to create another topic to discuss

Regarding this All the indexes were registered. Please ignore, is my mistake.

Thanks Clive ok, so far we are good then ?

Yeah for every new issue you find please create a new topic. That will help you and me track it down together.

Just curious, so far how does it look over all ?

So far quite good. :grinning: I have only touch the basic stuffs. So i had not had a chance to touch on rest of the stuffs but eventually will.

Sounds good. I am always here to help !


1 Like