From a8f0fc0c389c48340fd83780137e9f48a3932c8e Mon Sep 17 00:00:00 2001 From: Jatin Garg <48029724+jatgarg@users.noreply.github.com> Date: Mon, 4 Nov 2024 16:43:29 -0800 Subject: [PATCH] build(client): Tag asserts for release 2.5.0 (#22975) ## Description Tag asserts short codes before Minor release Co-authored-by: Jatin Garg --- .../tree/src/shared-tree-core/editManager.ts | 26 +++++++++++++----- .../tree/src/shared-tree/independentView.ts | 2 +- .../dds/tree/src/shared-tree/treeApiAlpha.ts | 5 +++- .../dds/tree/src/shared-tree/treeCheckout.ts | 5 +++- .../src/odspDocumentDeltaConnection.ts | 2 +- .../src/channelCollection.ts | 2 +- .../container-runtime/src/containerRuntime.ts | 2 +- .../container-runtime/src/dataStoreContext.ts | 12 ++++++--- .../runtime/datastore/src/dataStoreRuntime.ts | 2 +- .../datastore/src/remoteChannelContext.ts | 10 +++++-- .../src/assertionShortCodesMap.ts | 27 ++++++++++++++----- 11 files changed, 69 insertions(+), 26 deletions(-) diff --git a/packages/dds/tree/src/shared-tree-core/editManager.ts b/packages/dds/tree/src/shared-tree-core/editManager.ts index c089855969f1..8e7e775e5a48 100644 --- a/packages/dds/tree/src/shared-tree-core/editManager.ts +++ b/packages/dds/tree/src/shared-tree-core/editManager.ts @@ -424,15 +424,24 @@ export class EditManager< } else { Reflect.defineProperty(commit, "change", { get: () => - assert(false, "Should not access 'change' property of an evicted commit"), + assert( + false, + 0xa5e /* Should not access 'change' property of an evicted commit */, + ), }); Reflect.defineProperty(commit, "revision", { get: () => - assert(false, "Should not access 'revision' property of an evicted commit"), + assert( + false, + 0xa5f /* Should not access 'revision' property of an evicted commit */, + ), }); Reflect.defineProperty(commit, "parent", { get: () => - assert(false, "Should not access 'parent' property of an evicted commit"), + assert( + false, + 0xa60 /* Should not access 'parent' property of an evicted commit */, + ), }); return { delete: true }; } @@ -491,7 +500,10 @@ export class EditManager< const trunk = getPathFromBase(this.trunk.getHead(), oldestCommitInCollabWindow).map( (c) => { - assert(c !== this.trunkBase, "Serialized trunk should not include the trunk base"); + assert( + c !== this.trunkBase, + 0xa61 /* Serialized trunk should not include the trunk base */, + ); const metadata = this.trunkMetadata.get(c.revision) ?? fail("Expected metadata for trunk commit"); const commit: SequencedCommit = { @@ -522,7 +534,7 @@ export class EditManager< commits: branchPath.map((c) => { assert( c !== this.trunkBase, - "Serialized branch should not include the trunk base", + 0xa62 /* Serialized branch should not include the trunk base */, ); const commit: Commit = { change: c.change, @@ -593,7 +605,7 @@ export class EditManager< if (id === undefined) { assert( trunkCommitOrTrunkBase === this.trunkBase, - "Commit must be either be on the trunk or be the trunk base", + 0xa63 /* Commit must be either be on the trunk or be the trunk base */, ); return minimumPossibleSequenceId; } @@ -652,7 +664,7 @@ export class EditManager< assert( sequenceNumber >= // This is ">=", not ">" because changes in the same batch will have the same sequence number (this.sequenceMap.maxKey()?.sequenceNumber ?? minimumPossibleSequenceNumber), - "Attempted to sequence change with an outdated sequence number", + 0xa64 /* Attempted to sequence change with an outdated sequence number */, ); const commitsSequenceNumber = this.getBatch(sequenceNumber); diff --git a/packages/dds/tree/src/shared-tree/independentView.ts b/packages/dds/tree/src/shared-tree/independentView.ts index bd3f47cb16b6..0ef5c6fef873 100644 --- a/packages/dds/tree/src/shared-tree/independentView.ts +++ b/packages/dds/tree/src/shared-tree/independentView.ts @@ -113,7 +113,7 @@ export function independentInitializedView { - assert(previousMessage !== undefined, "previous message must exist"); + assert(previousMessage !== undefined, 0xa67 /* previous message must exist */); this.ensureNoDataModelChanges(() => { this.validateAndProcessRuntimeMessages( // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/packages/runtime/container-runtime/src/dataStoreContext.ts b/packages/runtime/container-runtime/src/dataStoreContext.ts index e0f10b6bf2b3..77678baa026e 100644 --- a/packages/runtime/container-runtime/src/dataStoreContext.ts +++ b/packages/runtime/container-runtime/src/dataStoreContext.ts @@ -605,11 +605,14 @@ export abstract class FluidDataStoreContext this.summarizerNode.recordChange(envelope as ISequencedDocumentMessage); if (this.loaded) { - assert(this.channel !== undefined, "Channel is not loaded"); + assert(this.channel !== undefined, 0xa68 /* Channel is not loaded */); this.processMessagesCompat(this.channel, messageCollection); } else { assert(!local, 0x142 /* "local store channel is not loaded" */); - assert(this.pendingMessagesState !== undefined, "pending messages queue is undefined"); + assert( + this.pendingMessagesState !== undefined, + 0xa69 /* pending messages queue is undefined */, + ); this.pendingMessagesState.messageCollections.push({ ...messageCollection, messagesContent: Array.from(messagesContent), @@ -829,7 +832,10 @@ export abstract class FluidDataStoreContext protected processPendingOps(channel: IFluidDataStoreChannel) { const baseSequenceNumber = this.baseSnapshotSequenceNumber ?? -1; - assert(this.pendingMessagesState !== undefined, "pending messages queue is undefined"); + assert( + this.pendingMessagesState !== undefined, + 0xa6a /* pending messages queue is undefined */, + ); for (const messageCollection of this.pendingMessagesState.messageCollections) { // Only process ops whose seq number is greater than snapshot sequence number from which it loaded. if (messageCollection.envelope.sequenceNumber > baseSequenceNumber) { diff --git a/packages/runtime/datastore/src/dataStoreRuntime.ts b/packages/runtime/datastore/src/dataStoreRuntime.ts index b8fcddabf635..05a3dacde046 100644 --- a/packages/runtime/datastore/src/dataStoreRuntime.ts +++ b/packages/runtime/datastore/src/dataStoreRuntime.ts @@ -689,7 +689,7 @@ export class FluidDataStoreRuntime // process the last set of channel ops const channelContext = this.contexts.get(currentAddress); - assert(!!channelContext, "Channel context not found"); + assert(!!channelContext, 0xa6b /* Channel context not found */); channelContext.processMessages({ envelope: messageCollection.envelope, diff --git a/packages/runtime/datastore/src/remoteChannelContext.ts b/packages/runtime/datastore/src/remoteChannelContext.ts index 7f97c9aa2399..ce5c78a4d65b 100644 --- a/packages/runtime/datastore/src/remoteChannelContext.ts +++ b/packages/runtime/datastore/src/remoteChannelContext.ts @@ -105,7 +105,10 @@ export class RemoteChannelContext implements IChannelContext { this.id, ); - assert(this.pendingMessagesState !== undefined, "pending messages state is undefined"); + assert( + this.pendingMessagesState !== undefined, + 0xa6c /* pending messages state is undefined */, + ); for (const messageCollection of this.pendingMessagesState.messageCollections) { this.services.deltaConnection.processMessages(messageCollection); } @@ -180,7 +183,10 @@ export class RemoteChannelContext implements IChannelContext { this.services.deltaConnection.processMessages(messageCollection); } else { assert(!local, 0x195 /* "Remote channel must not be local when processing op" */); - assert(this.pendingMessagesState !== undefined, "pending messages queue is undefined"); + assert( + this.pendingMessagesState !== undefined, + 0xa6d /* pending messages queue is undefined */, + ); this.pendingMessagesState.messageCollections.push({ ...messageCollection, messagesContent: Array.from(messagesContent), diff --git a/packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts b/packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts index 7ff31407d81c..78e4bf79178c 100644 --- a/packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts +++ b/packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts @@ -211,7 +211,6 @@ export const shortCodeMap = { "0x119": "This agent became inactive while releasing", "0x11a": "Unsuccessful registration", "0x11b": "Trying to clear tasks on inactive agent", - "0x11c": "Detached object routing context", "0x11d": "task is already running", "0x11e": "client is undefined", "0x11f": "requesting unknown blobs", @@ -282,7 +281,6 @@ export const shortCodeMap = { "0x182": "Data store should be attached to attach the channel.", "0x183": "There should be a channel context for the op", "0x184": "There should be a channel context for the op", - "0x185": "Channel not found", "0x189": "Should always be remote because a local dds shouldn't generate ops before loading", "0x18a": "Channel should be loaded to resubmit ops", "0x18d": "Channel should be loaded to take snapshot", @@ -380,9 +378,6 @@ export const shortCodeMap = { "0x236": "In all cases it should be already installed", "0x238": "called only in connected state", "0x23a": "seq#'s", - "0x23d": "pending is undefined", - "0x23e": "pending is undefined", - "0x23f": "pending undefined", "0x241": "Trying to send noop without active connection", "0x242": "has timer", "0x243": "Expected a noop to be synchronously sent", @@ -587,7 +582,6 @@ export const shortCodeMap = { "0x3cd": "Connection is possible only if container exists in storage", "0x3cf": "reentrancy", "0x3d0": "clientSequenceNumber can't be negative", - "0x3d1": "Can't trigger summary in the middle of a batch", "0x3d2": "Non-attached container is dirty", "0x3d3": "if doc is dirty, there has to be pending ops", "0x3d4": "System op in the middle of a batch", @@ -1621,5 +1615,24 @@ export const shortCodeMap = { "0xa57": "Expected EagerMapTree required field to have a value", "0xa58": "Signal must have a client ID", "0xa59": "Client connected without clientId", - "0xa5a": "Mismatched SessionId" + "0xa5a": "Mismatched SessionId", + "0xa5b": "must have exactly 1 field in batch", + "0xa5c": "Unexpected view implementation", + "0xa5d": "The main branch cannot be rebased onto another branch.", + "0xa5e": "Should not access 'change' property of an evicted commit", + "0xa5f": "Should not access 'revision' property of an evicted commit", + "0xa60": "Should not access 'parent' property of an evicted commit", + "0xa61": "Serialized trunk should not include the trunk base", + "0xa62": "Serialized branch should not include the trunk base", + "0xa63": "Commit must be either be on the trunk or be the trunk base", + "0xa64": "Attempted to sequence change with an outdated sequence number", + "0xa65": "documentId is required when multiplexing is enabled.", + "0xa66": "Context not found", + "0xa67": "previous message must exist", + "0xa68": "Channel is not loaded", + "0xa69": "pending messages queue is undefined", + "0xa6a": "pending messages queue is undefined", + "0xa6b": "Channel context not found", + "0xa6c": "pending messages state is undefined", + "0xa6d": "pending messages queue is undefined" };