pjfanning opened a new issue, #634:
URL: https://github.com/apache/pekko-projection/issues/634

   ### Problem
   `FilterStage.mapEntityIdToPid` builds the persistence id for consumer filter 
criteria (`IncludeEntityIds`, `ExcludeEntityIds`, etc.). For plain entity ids 
it uses the stream's `entityType`, but for replicated entity ids (containing 
the `|` separator) it uses the `streamId`:
   
   
https://github.com/apache/pekko-projection/blob/main/grpc/src/main/scala/org/apache/pekko/projection/grpc/internal/FilterStage.scala#L283-L289
   
   ```scala
   private def mapEntityIdToPid(entityId: String): String = {
     if (entityId.indexOf(ReplicationIdSeparator) < 0)
       PersistenceId(entityType, entityId).id
     else
       
ReplicationId.fromString(s"$streamId$ReplicationIdSeparator$entityId").persistenceId.id
   }
   ```
   
   For Replicated Event Sourcing the stream id defaults to 
`entityTypeKey.name`, so this works in the default case. When 
`ReplicationSettings.withStreamId` is used to give the stream a different id, 
the constructed persistence id has the wrong type name, so the slice check and 
the replay query for that entity id don't match any events.
   
   ### Suggested fix
   Use `entityType` in both branches, in line with the comment above the method 
("Translate the streamId to the entityType and thereby constructing the full 
persistenceId"). A `FilterStageSpec` test with `streamId != entityType` and a 
replicated entity id in `IncludeEntityIds` would cover it.
   
   ### References
   Refs #633 - the same stream id / entity type distinction for `ReplayReq`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to