couchbase-rs icon indicating copy to clipboard operation
couchbase-rs copied to clipboard

Utf8Error on get operation

Open carolfly86 opened this issue 5 years ago • 1 comments
trafficstars

Hi,

I have a simple code to get document by key:

match block_on(_collection.get(key, GetOptions::default())) {
        Ok(r) => {
            let decoded: db::WritableEnvironment = match r.content(){
                Ok(environment) => environment,
                Err(e) => {
                    warn!("Unable to get couchbase document");
                    return Err(e.into());
                }
            };
            Ok(Some(decoded.into()))
        },
        Err(e) => {
            match e {
                CouchbaseError::DocumentNotFound {ctx: _} =>{
                    info!("couchbase document not found");
                    Ok(None)
                }
                _ => {
                    info!("get failed! {}", e);
                    Err(e.into())
                }            
            }
        }
    } 

This occasionally fails with below error:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Utf8Error { valid_up_to: 14, error_len: Some(1) }', /Users/xxx/.cargo/registry/src/github.com-1ecc6299db9ec823/couchbase-1.0.0-alpha.3/src/io/lcb/callbacks.rs:185:42

my couchbase document keys consists of 7 digits sha, double colons, and a short string containing character and digits. For example the above error message is caused by trying to get this key 9a59b6e::S555

However, this error happens occasionally for different keys, and it may succeed in the next run. Any idea what it could be? I'm using the 1.47.0-nightly version of rustc.

carolfly86 avatar Aug 11 '20 15:08 carolfly86

@carolfly86 thanks for reporting! Are you on master or a specific version of the sdk?

daschl avatar Aug 24 '20 11:08 daschl