node-ottoman icon indicating copy to clipboard operation
node-ottoman copied to clipboard

DocumentNotFound Exception

Open AV25242 opened this issue 4 years ago • 5 comments

In the 04/13 meeting with the customer it was determined that the following mutation operations are not throwing back DocumentNotFound Exception

findOneAndUpdate
removeById
replaceById
updateById
findOne

Can someone please verify to see what could be the reason ? If its Nodejs SDK not throwing back the exception we will need to know ASAP.

AV25242 avatar Apr 14 '21 14:04 AV25242

@AV25242 in the file couchnode\lib\errors.js of the sdk adding this change in the method of line 16:

class CouchbaseError extends Error {
  constructor(errtext, baseerr, context, ...args) {
    super(errtext, ...args);
    this.cause = baseerr;
    this.context = context;
    this.name = this.constructor.name; // 👈👈👈 adding this line the errors comes out with the corresponding name
    Error.captureStackTrace(this, CouchbaseError);
  }
}

exports.CouchbaseError = CouchbaseError;

The errors would be showing with their corresponding names, example:

const CatSchema = new Schema({
  name: String,
  age: Number,
});

const Cat = model('Cat', CatSchema);

try {
  await Cat.updateById('id-no-found', {})
} catch (e) {
  const { name, message } = e;
  console.log(`Name: ${JSON.stringify(name)}`);
  console.log(`Message: ${JSON.stringify(message)}`);
}

// OUTPUT with update

Name: "DocumentNotFoundError"
Message: "document not found"

// OUTPUT without update

Name: "Error"
Message: "document not found" (editado) 

ariamF11 avatar Apr 15 '21 11:04 ariamF11

@gsi-ariam thanks much, I have reported this information in the Nodejs ticket and made @brett19 aware of this, he will evaluate it.

AV25242 avatar Apr 15 '21 19:04 AV25242

related to #356

AV25242 avatar Apr 15 '21 19:04 AV25242

@gsi-alejandro and @gsi-ariam the underlying SDK issue https://issues.couchbase.com/browse/JSCBC-855 seems to be getting released today with SDK 3.2 Beta please do the necessary changes on Ottoman side

AV25242 avatar May 17 '21 17:05 AV25242

@AV25242 according to Brett: "SDK currently only supports our internal builds."

I even tried uploading the couchbase version to 3.1.3 and it doesn't work either it gives the same error as the 3.2-beta version:

Error: LCB_ERR_KVENGINE_INVALID_PACKET (1031): A badly formatted packet was sent to the server. Please report this in a bug

ariamF11 avatar Jun 04 '21 14:06 ariamF11