Web console fails to retrieve document after insertion of corrupted data

couchbase

Hi,
I am using C SDK to store documents.
I inserted some normal documents and some corrupted - for example, Unicode characters in the key and in the document. After insertion of corrupted keys/documents “Retrieve Docs” on the Web Console fails for all documents (see attached image with error)
If I use “Classic Editor”, I can see documents but cannot delete corrupted entries.
What is the best practice to recover/clean up the Bucket?

Is it ok that I killed the view so easily?

Regards,
Marina

Hi Marina,

Could you post an example of how you created a document like this, so that it can be reproduced?

Please see the code below that does store a new document
To easily recreate the problem you can use key like:
///////////////////////////////////////////////////////////
char tmp[16]; // This is a bad key
memset(tmp, 0, 16);
tmp[0] = ‘G’;
tmp[2] = ‘.’;
key size =3;
///////////////////////////////////////////////////

void CDbMgrEntity::StoreBadDocument(QString key, QByteArray val)
{
lcb_CMDSTORE *scmd;

lcb_cmdstore_create(&scmd, LCB_STORE_SET);
lcb_STATUS err;

char tmp[16]; // This is a bad key
memset(tmp, 0, 16);
tmp[0] = ‘G’;
tmp[2] = ‘.’;

char ValStr = (char)malloc(val.size()+2);
memset(ValStr, ‘\0’, val.size()+2);
sprintf(ValStr, val.toStdString().data());
m_logger->info("{}\n\n", ValStr);
lcb_cmdstore_key(scmd, tmp, 3);

lcb_cmdstore_value(scmd, ValStr, val.size());
err = lcb_store(m_DbInstance, NULL, scmd);
lcb_cmdstore_destroy(scmd);
free(ValStr);
if (err != LCB_SUCCESS) {
m_logger->error("{} Couldn’t schedule storage operation {}\n",FUNCN, err);
}
/* The store_callback is invoked from lcb_wait() */
fprintf(stderr, “Will wait for storage operation to complete…\n”);
lcb_wait(m_DbInstance);
}