Skip to content

Commit

Permalink
Correction for objectID issue in last merge (#86)
Browse files Browse the repository at this point in the history
The last PR merged decode the objectID as either string or objectId
type, but would fail on binary objectIDs. The prior implementation had
converted the objectID to an interface{} type, to be handled downstream,
so this moves back to that approach, while still limiting the
unmarshaling to just the _id field.
  • Loading branch information
eparker-tulip authored Oct 3, 2024
1 parent 0646efb commit 8b3094e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

buildGoModule {
pname = "oplogtoredis";
version = "3.7.0";
version = "3.7.1";
src = builtins.path { path = ./.; };

postInstall = ''
Expand Down
18 changes: 5 additions & 13 deletions lib/oplog/tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,21 +510,13 @@ func (tailer *Tailer) parseRawOplogEntry(entry rawOplogEntry, txIdx *uint) []opl
} else {
idLookup := entry.Doc.Lookup("_id")
if idLookup.IsZero() {
log.Log.Errorf("failed to get objectId: _id is empty or not set")
log.Log.Error("failed to get objectId: _id is empty or not set")
return nil
}
oid, ok := idLookup.ObjectIDOK()
if ok {
// this is left as ObjectID type for now so it can be properly converted in processor.go:56
out.DocID = oid
} else {
oidString, ok := idLookup.StringValueOK()
if ok {
out.DocID = oidString
} else {
log.Log.Errorf("failed to get objectId: _id is not ObjectID or String type")
return nil
}
err := idLookup.Unmarshal(&out.DocID)
if err != nil {
log.Log.Errorf("failed to unmarshal objectId: %v", err)
return nil
}
}

Expand Down

0 comments on commit 8b3094e

Please sign in to comment.