diff --git a/ee/indexeddb/indexeddb.go b/ee/indexeddb/indexeddb.go index 97fe8da61..6a4959518 100644 --- a/ee/indexeddb/indexeddb.go +++ b/ee/indexeddb/indexeddb.go @@ -46,14 +46,14 @@ func QueryIndexeddbObjectStore(dbLocation string, dbName string, objectStoreName DisableSeeksCompaction: true, // no need to perform compaction Strict: opt.StrictAll, } - db, err := leveldb.OpenFile(tempDbCopyLocation, opts) - if err != nil { + db, dbOpenErr := leveldb.OpenFile(tempDbCopyLocation, opts) + if dbOpenErr != nil { // Perform recover in case we missed something while copying - db, err = leveldb.RecoverFile(tempDbCopyLocation, opts) - } - - if err != nil { - return nil, fmt.Errorf("opening db: %w", err) + var dbRecoverErr error + db, dbRecoverErr = leveldb.RecoverFile(tempDbCopyLocation, opts) + if dbRecoverErr != nil { + return nil, fmt.Errorf("opening db: `%+v`; recovering db: %w", dbOpenErr, dbRecoverErr) + } } defer db.Close() diff --git a/ee/indexeddb/values.go b/ee/indexeddb/values.go index 9ce9c5233..170ebcc68 100644 --- a/ee/indexeddb/values.go +++ b/ee/indexeddb/values.go @@ -129,7 +129,7 @@ func deserializeObject(ctx context.Context, slogger *slog.Logger, srcReader io.B for i := 0; i < int(objPropertyNameLen); i += 1 { nextByte, err := srcReader.ReadByte() if err != nil { - return obj, fmt.Errorf("reading next byte in object property name string: %w", err) + return obj, fmt.Errorf("reading next byte in object property name string of length %d: %w; partial object property name: `%s`", objPropertyNameLen, err, string(objPropertyBytes)) } objPropertyBytes[i] = nextByte @@ -140,7 +140,7 @@ func deserializeObject(ctx context.Context, slogger *slog.Logger, srcReader io.B // Now process the object property's value. The next byte will tell us its type. nextByte, err := nextNonPaddingByte(srcReader) if err != nil { - return obj, fmt.Errorf("reading next byte: %w", err) + return obj, fmt.Errorf("reading next byte for `%s`: %w", currentPropertyName, err) } // Handle the object property value by its type. @@ -149,21 +149,21 @@ func deserializeObject(ctx context.Context, slogger *slog.Logger, srcReader io.B // Object nested inside this object nestedObj, err := deserializeNestedObject(ctx, slogger, srcReader) if err != nil { - return obj, fmt.Errorf("decoding nested object for %s: %w", currentPropertyName, err) + return obj, fmt.Errorf("decoding nested object for `%s`: %w", currentPropertyName, err) } obj[currentPropertyName] = nestedObj case tokenAsciiStr: // ASCII string strVal, err := deserializeAsciiStr(srcReader) if err != nil { - return obj, fmt.Errorf("decoding ascii string for %s: %w", currentPropertyName, err) + return obj, fmt.Errorf("decoding ascii string for `%s`: %w", currentPropertyName, err) } obj[currentPropertyName] = strVal case tokenUtf16Str: // UTF-16 string strVal, err := deserializeUtf16Str(srcReader) if err != nil { - return obj, fmt.Errorf("decoding ascii string for %s: %w", currentPropertyName, err) + return obj, fmt.Errorf("decoding ascii string for `%s`: %w", currentPropertyName, err) } obj[currentPropertyName] = strVal case tokenTrue: @@ -175,19 +175,19 @@ func deserializeObject(ctx context.Context, slogger *slog.Logger, srcReader io.B case tokenInt32: propertyInt, err := binary.ReadVarint(srcReader) if err != nil { - return obj, fmt.Errorf("decoding int32 for %s: %w", currentPropertyName, err) + return obj, fmt.Errorf("decoding int32 for `%s`: %w", currentPropertyName, err) } obj[currentPropertyName] = []byte(strconv.Itoa(int(propertyInt))) case tokenBeginSparseArray: arr, err := deserializeSparseArray(ctx, slogger, srcReader) if err != nil { - return obj, fmt.Errorf("decoding sparse array for %s: %w", currentPropertyName, err) + return obj, fmt.Errorf("decoding sparse array for `%s`: %w", currentPropertyName, err) } obj[currentPropertyName] = arr case tokenBeginDenseArray: arr, err := deserializeDenseArray(ctx, slogger, srcReader) if err != nil { - return obj, fmt.Errorf("decoding dense array for %s: %w", currentPropertyName, err) + return obj, fmt.Errorf("decoding dense array for `%s`: %w", currentPropertyName, err) } obj[currentPropertyName] = arr case tokenPadding, tokenVerifyObjectCount: @@ -196,6 +196,7 @@ func deserializeObject(ctx context.Context, slogger *slog.Logger, srcReader io.B default: slogger.Log(ctx, slog.LevelWarn, "unknown token type", + "current_property_name", currentPropertyName, "token", fmt.Sprintf("%02x", nextByte), ) continue diff --git a/ee/katc/deserialize_firefox.go b/ee/katc/deserialize_firefox.go index a06c89c0c..d7888f8fa 100644 --- a/ee/katc/deserialize_firefox.go +++ b/ee/katc/deserialize_firefox.go @@ -127,7 +127,7 @@ func deserializeObject(srcReader io.ByteReader) (map[string][]byte, error) { case tagString, tagStringObject: str, err := deserializeString(valData, srcReader) if err != nil { - return nil, fmt.Errorf("reading string for key %s: %w", nextKeyStr, err) + return nil, fmt.Errorf("reading string for key `%s`: %w", nextKeyStr, err) } resultObj[nextKeyStr] = str case tagBoolean: @@ -139,19 +139,19 @@ func deserializeObject(srcReader io.ByteReader) (map[string][]byte, error) { case tagObjectObject: obj, err := deserializeNestedObject(srcReader) if err != nil { - return nil, fmt.Errorf("reading object for key %s: %w", nextKeyStr, err) + return nil, fmt.Errorf("reading object for key `%s`: %w", nextKeyStr, err) } resultObj[nextKeyStr] = obj case tagArrayObject: arr, err := deserializeArray(valData, srcReader) if err != nil { - return nil, fmt.Errorf("reading array for key %s: %w", nextKeyStr, err) + return nil, fmt.Errorf("reading array for key `%s`: %w", nextKeyStr, err) } resultObj[nextKeyStr] = arr case tagNull, tagUndefined: resultObj[nextKeyStr] = nil default: - return nil, fmt.Errorf("cannot process %s: unknown tag type %x", nextKeyStr, valTag) + return nil, fmt.Errorf("cannot process object key `%s`: unknown tag type `%x` with data `%d`", nextKeyStr, valTag, valData) } }