Skip to content

Commit a53f222

Browse files
jatgargJatin Garg
andauthored
Assert that clientId should be present in client ops for OpStreamAttributor (#20717)
## Description [Task Link](https://dev.azure.com/fluidframework/internal/_workitems/edit/7711) Add assert that clientId should be present for ops of type MessageType.op in OpStreamAttributtor. Co-authored-by: Jatin Garg <[email protected]>
1 parent 3620b0a commit a53f222

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/framework/attributor/src/attributor.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { type IDeltaManager } from "@fluidframework/container-definitions";
77
import { assert } from "@fluidframework/core-utils/internal";
88
import {
9+
MessageType,
910
type IDocumentMessage,
1011
type IQuorumClients,
1112
type ISequencedDocumentMessage,
@@ -91,10 +92,12 @@ export class OpStreamAttributor extends Attributor implements IAttributor {
9192
) {
9293
super(initialEntries);
9394
deltaManager.on("op", (message: ISequencedDocumentMessage) => {
94-
// TODO: Verify whether this should be able to handle server-generated ops (with null clientId)
95-
const client = quorumClients.getMember(message.clientId as string);
96-
if (message.type === "op") {
97-
// TODO: This case may be legitimate, and if so we need to figure out how to handle it.
95+
if (message.type === MessageType.Operation) {
96+
assert(
97+
typeof message.clientId === "string",
98+
"Client id should be present and should be of type string",
99+
);
100+
const client = quorumClients.getMember(message.clientId);
98101
assert(client !== undefined, "Received message from user not in the quorumClients");
99102
this.keyToInfo.set(message.sequenceNumber, {
100103
user: client.client.user,

0 commit comments

Comments
 (0)