Skip to content

Commit

Permalink
build(client): Tag asserts for release 2.5.0 (#22975)
Browse files Browse the repository at this point in the history
## Description

Tag asserts short codes before Minor release

Co-authored-by: Jatin Garg <jatingarg@Jatins-MacBook-Pro-2.local>
  • Loading branch information
2 people authored and Josmithr committed Nov 5, 2024
1 parent da5d27f commit a8f0fc0
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 26 deletions.
26 changes: 19 additions & 7 deletions packages/dds/tree/src/shared-tree-core/editManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down Expand Up @@ -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<TChangeset> = {
Expand Down Expand Up @@ -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<TChangeset> = {
change: c.change,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/dds/tree/src/shared-tree/independentView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function independentInitializedView<const TSchema extends ImplicitFieldSc
};

const fieldCursors = fieldBatchCodec.decode(content.tree as JsonCompatibleReadOnly, context);
assert(fieldCursors.length === 1, "must have exactly 1 field in batch");
assert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);
// Checked above.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const cursors = fieldCursorToNodesCursors(fieldCursors[0]!);
Expand Down
5 changes: 4 additions & 1 deletion packages/dds/tree/src/shared-tree/treeApiAlpha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ export const TreeAlpha: {
return undefined;
}
const view = kernel.anchorNode.anchorSet.slots.get(ViewSlot);
assert(view instanceof SchematizingSimpleTreeView, "Unexpected view implementation");
assert(
view instanceof SchematizingSimpleTreeView,
0xa5c /* Unexpected view implementation */,
);
return view;
},

Expand Down
5 changes: 4 additions & 1 deletion packages/dds/tree/src/shared-tree/treeCheckout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,10 @@ export class TreeCheckout implements ITreeCheckoutFork {
!checkout.transaction.inProgress(),
0x9af /* A view cannot be rebased while it has a pending transaction */,
);
assert(checkout.isBranch, "The main branch cannot be rebased onto another branch.");
assert(
checkout.isBranch,
0xa5d /* The main branch cannot be rebased onto another branch. */,
);
checkout._branch.rebaseOnto(this._branch);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {

assert(
documentId !== undefined,
"documentId is required when multiplexing is enabled.",
0xa65 /* documentId is required when multiplexing is enabled. */,
);

if (documentId !== this.documentId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ export class ChannelCollection implements IFluidDataStoreChannel, IDisposable {
return;
}
const currentContext = this.contexts.get(currentMessageState.address);
assert(!!currentContext, "Context not found");
assert(!!currentContext, 0xa66 /* Context not found */);

currentContext.processMessages({
envelope: { ...messageCollection.envelope, type: currentMessageState.type },
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/container-runtime/src/containerRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2928,7 +2928,7 @@ export class ContainerRuntime

// Helper that processes the previous bunch of messages.
const sendBunchedMessages = () => {
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
Expand Down
12 changes: 9 additions & 3 deletions packages/runtime/container-runtime/src/dataStoreContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/datastore/src/dataStoreRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 8 additions & 2 deletions packages/runtime/datastore/src/remoteChannelContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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),
Expand Down
27 changes: 20 additions & 7 deletions packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
};

0 comments on commit a8f0fc0

Please sign in to comment.