Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions cmd/lfx-v1-sync-helper/ingest_dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"time"

"github.com/nats-io/nats.go/jetstream"
"github.com/vmihailenco/msgpack/v5"
)

// DynamoDBStreamEvent mirrors the JSON payload published by the dynamodb-stream-consumer.
Expand Down Expand Up @@ -118,11 +117,8 @@ func handleDynamoDBUpsert(ctx context.Context, event *DynamoDBStreamEvent) bool

var existingData map[string]interface{}
if unmarshalErr := json.Unmarshal(existing.Value(), &existingData); unmarshalErr != nil {
if msgpackErr := msgpack.Unmarshal(existing.Value(), &existingData); msgpackErr != nil {
logger.With(errKey, unmarshalErr, "msgpack_error", msgpackErr, "key", key).
ErrorContext(ctx, "failed to unmarshal existing KV entry")
logger.With(errKey, unmarshalErr, "key", key).ErrorContext(ctx, "failed to unmarshal existing KV entry")
return false
}
}
Comment on lines 119 to 122
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code now always uses JSON encoding for DynamoDB events. However, if any existing KV entries were previously stored in msgpack format (when cfg.UseMsgpack was true), this code will now fail to unmarshal them since the msgpack fallback has been removed. Consider documenting this breaking change or adding a migration path if there's existing msgpack-encoded data in the v1-objects KV bucket from DynamoDB sources.

Copilot uses AI. Check for mistakes.

if !shouldDynamoDBUpdate(ctx, event.NewImage, existingData, key) {
Expand All @@ -131,12 +127,7 @@ func handleDynamoDBUpsert(ctx context.Context, event *DynamoDBStreamEvent) bool
}
}

var dataBytes []byte
if cfg.UseMsgpack {
dataBytes, err = msgpack.Marshal(event.NewImage)
} else {
dataBytes, err = json.Marshal(event.NewImage)
}
dataBytes, err := json.Marshal(event.NewImage)
if err != nil {
logger.With(errKey, err, "key", key).ErrorContext(ctx, "failed to marshal DynamoDB event data")
return false
Expand Down