Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(client): Tag asserts for release 2.12.0 #23333

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/dds/shared-object-base/src/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class FluidSerializer implements IFluidSerializer {
private readonly encodeValue = (value: unknown, bind?: IFluidHandleInternal): unknown => {
// If 'value' is an IFluidHandle return its encoded form.
if (isFluidHandle(value)) {
assert(bind !== undefined, "Cannot encode a handle without a bind context");
assert(bind !== undefined, 0xa93 /* Cannot encode a handle without a bind context */);
return this.serializeHandle(toFluidHandleInternal(value), bind);
}
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ export class AnchorTreeIndex<TKey extends TreeIndexKey, TValue>
detachedCursor.free();
},
afterAttach: () => {
assert(parent !== undefined, "must have a parent");
assert(parent !== undefined, 0xa99 /* must have a parent */);
this.reIndexSpine(parent);
},
afterDetach: () => {
assert(parent !== undefined, "must have a parent");
assert(parent !== undefined, 0xa9a /* must have a parent */);
this.reIndexSpine(parent);
},
// when a replace happens, the keys of previously indexed nodes could be changed so we must re-index them
Expand Down Expand Up @@ -318,7 +318,10 @@ export class AnchorTreeIndex<TKey extends TreeIndexKey, TValue>
if (!this.isShallowIndex) {
const cursor = this.forest.allocateCursor();
this.forest.moveCursorToPath(path, cursor);
assert(cursor.mode === CursorLocationType.Nodes, "attach should happen in a node");
assert(
cursor.mode === CursorLocationType.Nodes,
0xa9b /* attach should happen in a node */,
);
cursor.exitNode();
this.indexSpine(cursor);
cursor.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class BranchCommitEnricher<TChange> {
* @remarks This will throw an error if there is no ongoing transaction.
*/
public addTransactionCommits(newCommits: Iterable<GraphCommit<TChange>>): void {
assert(this.#transactionEnricher.isTransacting(), "Not in transaction");
assert(this.#transactionEnricher.isTransacting(), 0xa97 /* Not in transaction */);
for (const commit of newCommits) {
this.#transactionEnricher.addTransactionStep(commit);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dds/tree/src/shared-tree-core/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class SquashingTransactionStack<
this.setTransactionBranch(transactionBranch);
transactionBranch.editor.enterTransaction();
return (result) => {
assert(this.#transactionBranch !== undefined, "Expected transaction branch");
assert(this.#transactionBranch !== undefined, 0xa98 /* Expected transaction branch */);
this.#transactionBranch.editor.exitTransaction();
switch (result) {
case TransactionResult.Abort:
Expand Down
7 changes: 5 additions & 2 deletions packages/dds/tree/src/shared-tree/sharedTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ function exportSimpleFieldSchemaStored(schema: TreeFieldStoredSchema): SimpleFie
break;
case FieldKinds.forbidden.identifier:
kind = FieldKind.Optional;
assert(schema.types.size === 0, "invalid forbidden field");
assert(schema.types.size === 0, 0xa94 /* invalid forbidden field */);
break;
default:
fail("invalid field kind");
Expand All @@ -693,7 +693,10 @@ function exportSimpleNodeSchemaStored(schema: TreeNodeStoredSchema): SimpleNodeS
return { kind: NodeKind.Object, fields };
}
if (schema instanceof MapNodeStoredSchema) {
assert(schema.mapFields.kind === FieldKinds.optional.identifier, "Invalid map schema");
assert(
schema.mapFields.kind === FieldKinds.optional.identifier,
0xa95 /* Invalid map schema */,
);
return { kind: NodeKind.Map, allowedTypes: schema.mapFields.types };
}
if (schema instanceof LeafNodeStoredSchema) {
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 @@ -492,7 +492,10 @@ export class TreeCheckout implements ITreeCheckoutFork {

let revision: RevisionTag | undefined;
if (event.type === "rebase") {
assert(hasSome(event.newCommits), "Expected new commit for non no-op change event");
assert(
hasSome(event.newCommits),
0xa96 /* Expected new commit for non no-op change event */,
);
revision = getLast(event.newCommits).revision;
} else {
revision = event.change.revision;
Expand Down
8 changes: 4 additions & 4 deletions packages/dds/tree/src/simple-tree/api/customTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ export function customFromCursorStored<TChild>(
const nodeSchema = schema.get(type) ?? fail("missing schema for type in cursor");

if (nodeSchema instanceof LeafNodeStoredSchema) {
assert(valueSchemaAllows(nodeSchema.leafValue, reader.value), "invalid value");
assert(valueSchemaAllows(nodeSchema.leafValue, reader.value), 0xa9c /* invalid value */);
return reader.value;
}

assert(reader.value === undefined, "out of schema: unexpected value");
assert(reader.value === undefined, 0xa9d /* out of schema: unexpected value */);

const arrayTypes = tryStoredSchemaAsArray(nodeSchema);
if (arrayTypes !== undefined) {
Expand All @@ -164,7 +164,7 @@ export function customFromCursorStored<TChild>(
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
fields[storedKey] = children[0]!;
} else {
assert(children.length === 0, "invalid children number");
assert(children.length === 0, 0xa9e /* invalid children number */);
}
});
return fields;
Expand All @@ -181,7 +181,7 @@ export function tryStoredSchemaAsArray(
if (schema instanceof ObjectNodeStoredSchema) {
const empty = schema.getFieldSchema(EmptyKey);
if (empty.kind === FieldKinds.sequence.identifier) {
assert(schema.objectNodeFields.size === 1, "invalid schema");
assert(schema.objectNodeFields.size === 1, 0xa9f /* invalid schema */);
return empty.types;
}
}
Expand Down
19 changes: 14 additions & 5 deletions packages/runtime/test-runtime-utils/src/assertionShortCodesMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,6 @@ export const shortCodeMap = {
"0x9df": "Key should be a string",
"0x9e0": "Value should be a number",
"0x9e1": "seqs and posBreakpoints length should match",
"0x9e4": "This wont run due to the length check above",
"0x9e5": "This wont run because a replace operation always has new commits",
"0x9e6": "unexpected schema kind",
"0x9e7": "invalid schema",
"0x9f0": "Expected build and destroy to have the same length",
Expand Down Expand Up @@ -1640,11 +1638,9 @@ export const shortCodeMap = {
"0xa7e": "Expected at least two types",
"0xa7f": "Delta manager does not have inbound/outbound queues.",
"0xa80": "Invalid delta manager",
"0xa81": "Expected new commit for non no-op change event",
"0xa82": "change to revert does not exist on the given forked branch",
"0xa83": "Expected commit(s) for a non no-op rebase",
"0xa84": "Commit must be in the branch's ancestry",
"0xa85": "Commit must be in the branch's ancestry",
"0xa86": "Expected source commits in non no-op merge",
"0xa87": "Expected resubmit queue to be non-empty",
"0xa88": "temporaryFileName should only be set for new file creation in the empty file create flow",
Expand All @@ -1657,5 +1653,18 @@ export const shortCodeMap = {
"0xa8f": "invalid operation on a disposed index",
"0xa90": "destroyed anchor node should be tracked by index",
"0xa91": "destroyed anchor node should be tracked by index",
"0xa92": "destroyed anchor should be tracked by index"
"0xa92": "destroyed anchor should be tracked by index",
"0xa93": "Cannot encode a handle without a bind context",
"0xa94": "invalid forbidden field",
"0xa95": "Invalid map schema",
"0xa96": "Expected new commit for non no-op change event",
"0xa97": "Not in transaction",
"0xa98": "Expected transaction branch",
"0xa99": "must have a parent",
"0xa9a": "must have a parent",
"0xa9b": "attach should happen in a node",
"0xa9c": "invalid value",
"0xa9d": "out of schema: unexpected value",
"0xa9e": "invalid children number",
"0xa9f": "invalid schema"
};
Loading