Skip to content

Commit 96cf6c5

Browse files
authored
Tag asserts for 2.71.0 release. (#25794)
This PR tags asserts for the upcoming 2.71.0 release. Changes generated with `pnpm run policy-check:asserts`
1 parent 15d422e commit 96cf6c5

File tree

6 files changed

+43
-19
lines changed

6 files changed

+43
-19
lines changed

packages/dds/counter/src/counter.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ export class SharedCounter
173173
if (local) {
174174
const pendingOp = this.pendingOps.shift();
175175
const messageId = messageContent.localOpMetadata;
176-
assert(typeof messageId === "number", "localOpMetadata should be a number");
176+
assert(typeof messageId === "number", 0xc8e /* localOpMetadata should be a number */);
177177
assert(
178178
pendingOp !== undefined &&
179179
pendingOp.messageId === messageId &&
180180
pendingOp.type === op.type &&
181181
pendingOp.incrementAmount === op.incrementAmount,
182-
"local op mismatch",
182+
0xc8f /* local op mismatch */,
183183
);
184184
} else {
185185
switch (op.type) {
@@ -215,14 +215,17 @@ export class SharedCounter
215215
*/
216216
protected rollback(content: unknown, localOpMetadata: unknown): void {
217217
assertIsIncrementOp(content);
218-
assert(typeof localOpMetadata === "number", "localOpMetadata should be a number");
218+
assert(
219+
typeof localOpMetadata === "number",
220+
0xc90 /* localOpMetadata should be a number */,
221+
);
219222
const pendingOp = this.pendingOps.pop();
220223
assert(
221224
pendingOp !== undefined &&
222225
pendingOp.messageId === localOpMetadata &&
223226
pendingOp.type === content.type &&
224227
pendingOp.incrementAmount === content.incrementAmount,
225-
"op to rollback mismatch with pending op",
228+
0xc91 /* op to rollback mismatch with pending op */,
226229
);
227230
// To rollback the optimistic increment we can increment by the opposite amount.
228231
// This will also emit another incremented event with the opposite amount.
@@ -238,6 +241,6 @@ function assertIsIncrementOp(op: unknown): asserts op is IIncrementOperation {
238241
"incrementAmount" in op &&
239242
op.type === "increment" &&
240243
typeof op.incrementAmount === "number",
241-
"invalid increment op format",
244+
0xc92 /* invalid increment op format */,
242245
);
243246
}

packages/dds/ordered-collection/src/consensusOrderedCollection.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,10 @@ export class ConsensusOrderedCollection<T = any>
442442
* @sealed
443443
*/
444444
protected rollback(content: unknown, localOpMetadata: unknown): void {
445-
assert(typeof localOpMetadata === "function", "localOpMetadata should be a function");
445+
assert(
446+
typeof localOpMetadata === "function",
447+
0xc93 /* localOpMetadata should be a function */,
448+
);
446449
// A resolve function is passed as the localOpMetadata on this.submitLocalMessage().
447450
// On rollback we resolve with undefined and the promises will handle it appropriately.
448451
const resolve = localOpMetadata as PendingResolve<T>;

packages/dds/tree/src/shared-tree/independentView.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ export function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSc
212212
assert(fieldCursors.length === 1, 0xa5b /* must have exactly 1 field in batch */);
213213

214214
const fieldCursor = oneFromIterable(fieldCursors);
215-
assert(fieldCursor !== undefined, "expected exactly one field in batch");
215+
assert(fieldCursor !== undefined, 0xc94 /* expected exactly one field in batch */);
216216

217217
initialize(
218218
checkout,

packages/dds/tree/src/simple-tree/node-kinds/object/objectNode.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,13 @@ function applyFieldChange(
767767
const proxy =
768768
from.kind === "proxy"
769769
? from.node
770-
: (targetToProxy.get(from.node) ?? fail("missing proxy"));
770+
: (targetToProxy.get(from.node) ?? fail(0xc95 /* missing proxy */));
771771
const inner = getInnerNode(proxy);
772772
const storedSchema = inner.context.schema.nodeSchema.get(brand(schema.identifier));
773-
assert(storedSchema instanceof ObjectNodeStoredSchema, "Expected ObjectNodeStoredSchema");
773+
assert(
774+
storedSchema instanceof ObjectNodeStoredSchema,
775+
0xc96 /* Expected ObjectNodeStoredSchema */,
776+
);
774777

775778
if (value === undefined && inner.tryGetField(fieldInfo.storedKey) === undefined) {
776779
return;

packages/framework/presence/src/getPresence.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ const presenceCompatibility = {
4040
function assertCompatibilityInvariants(compatibility: ExtensionCompatibilityDetails): void {
4141
assert(
4242
compatibility.generation === presenceCompatibility.generation,
43-
"Presence compatibility generation mismatch.",
43+
0xc97 /* Presence compatibility generation mismatch. */,
44+
);
45+
assert(
46+
compatibility.version.startsWith("2."),
47+
0xc98 /* Registered version is not major version 2. */,
4448
);
45-
assert(compatibility.version.startsWith("2."), "Registered version is not major version 2.");
4649
assert(
4750
Number.parseFloat(compatibility.version.slice(2)) <
4851
Number.parseFloat(presenceCompatibility.version.slice(2)),
49-
"Registered version is not less than the current version.",
52+
0xc99 /* Registered version is not less than the current version. */,
5053
);
5154
assert(
5255
presenceCompatibility.capabilities.size === 0,
53-
"Presence capabilities should be empty.",
56+
0xc9a /* Presence capabilities should be empty. */,
5457
);
5558
}
5659

@@ -91,7 +94,7 @@ class ContainerPresenceManager
9194
): never {
9295
assert(
9396
ourExistingInstantiation.compatibility === presenceCompatibility,
94-
"Presence extension called without own compatibility details",
97+
0xc9b /* Presence extension called without own compatibility details */,
9598
);
9699
assertCompatibilityInvariants(newCompatibilityRequest);
97100
// There have not yet been any changes that would require action to upgrade.
@@ -184,7 +187,7 @@ function assertContextHasExtensionProvider(
184187
): asserts context is FluidDataStoreContextInternal {
185188
assert(
186189
"getExtension" in context,
187-
"Data store context does not implement ContainerExtensionProvider",
190+
0xc9c /* Data store context does not implement ContainerExtensionProvider */,
188191
);
189192
}
190193

packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,6 @@ export const shortCodeMap = {
16961696
"0xb9e": "entryPoint must be of type IStaticEntryPoint",
16971697
"0xb9f": "entryPoint must be of type RootDataObject",
16981698
"0xba0": "No recipient found for local signal",
1699-
"0xba1": "Extension entry is not of the expected type",
17001699
"0xba2": "Reentrancy not allowed in BatchRunCounter",
17011700
"0xba3": "Mismatch in staged state tracking",
17021701
"0xba4": "local operation must have a pending array",
@@ -1792,7 +1791,6 @@ export const shortCodeMap = {
17921791
"0xc15": "Expected ObjectNodeStoredSchema",
17931792
"0xc16": "missing schema for array node",
17941793
"0xc17": "Expected MapNodeStoredSchema",
1795-
"0xc18": "Expected ObjectNodeStoredSchema",
17961794
"0xc19": "Expected FieldSchemaAlpha",
17971795
"0xc1a": "Expected MapNodeStoredSchema",
17981796
"0xc1b": "Expected at least two types",
@@ -1883,7 +1881,6 @@ export const shortCodeMap = {
18831881
"0xc7a": "No pending change stored for this revision",
18841882
"0xc7b": "missing anchor",
18851883
"0xc7c": "Unknown modular change format",
1886-
"0xc7d": "invalid AnnotatedAllowedTypes",
18871884
"0xc7e": "Pending blob already in redirect table",
18881885
"0xc7f": "Expected blob to be attached",
18891886
"0xc80": "Expect uploadAndAttach to be called with either localOnly or uploaded state",
@@ -1899,5 +1896,20 @@ export const shortCodeMap = {
18991896
"0xc8a": "catching up without clientId",
19001897
"0xc8b": "connected without clientId",
19011898
"0xc8c": "connected with different clientId than pending",
1902-
"0xc8d": "connection state mismatch between getConnectionState and setConnectionStatus notification"
1899+
"0xc8d": "connection state mismatch between getConnectionState and setConnectionStatus notification",
1900+
"0xc8e": "localOpMetadata should be a number",
1901+
"0xc8f": "local op mismatch",
1902+
"0xc90": "localOpMetadata should be a number",
1903+
"0xc91": "op to rollback mismatch with pending op",
1904+
"0xc92": "invalid increment op format",
1905+
"0xc93": "localOpMetadata should be a function",
1906+
"0xc94": "expected exactly one field in batch",
1907+
"0xc95": "missing proxy",
1908+
"0xc96": "Expected ObjectNodeStoredSchema",
1909+
"0xc97": "Presence compatibility generation mismatch.",
1910+
"0xc98": "Registered version is not major version 2.",
1911+
"0xc99": "Registered version is not less than the current version.",
1912+
"0xc9a": "Presence capabilities should be empty.",
1913+
"0xc9b": "Presence extension called without own compatibility details",
1914+
"0xc9c": "Data store context does not implement ContainerExtensionProvider"
19031915
};

0 commit comments

Comments
 (0)