Skip to content

Commit b13db34

Browse files
committed
fix: remove weak postcheck from validator removal to prevent idempotency skip
The validator-removal operation used a postcheck that matched options.validationLevel=strict, which was already satisfied when the original validator also used strict. This caused the idempotency probe to skip the collMod entirely, leaving the validator in place. Empty the postcheck array so the operation always executes. The collMod with validator:{} is inherently idempotent so no safety is lost.
1 parent 89ed81b commit b13db34

2 files changed

Lines changed: 3 additions & 15 deletions

File tree

packages/3-mongo-target/2-mongo-adapter/src/core/mongo-planner.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,17 +243,7 @@ function planValidatorDiff(
243243
}),
244244
},
245245
],
246-
postcheck: [
247-
{
248-
description: `validator removed from ${collName}`,
249-
source: new ListCollectionsCommand(),
250-
filter: MongoAndExpr.of([
251-
MongoFieldFilter.eq('name', collName),
252-
MongoFieldFilter.eq('options.validationLevel', 'strict'),
253-
]),
254-
expect: 'exists' as const,
255-
},
256-
],
246+
postcheck: [],
257247
};
258248
}
259249

packages/3-mongo-target/2-mongo-adapter/test/mongo-planner.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ describe('MongoMigrationPlanner', () => {
584584
expect(op.postcheck[0]!.expect).toBe('exists');
585585
});
586586

587-
it('validator remove has precheck and postcheck', () => {
587+
it('validator remove has precheck and empty postcheck', () => {
588588
const contract = makeContract({ users: {} });
589589
const origin: MongoSchemaIR = {
590590
collections: {
@@ -607,9 +607,7 @@ describe('MongoMigrationPlanner', () => {
607607
expect(op.precheck[0]!.source.kind).toBe('listCollections');
608608
expect(op.precheck[0]!.expect).toBe('exists');
609609

610-
expect(op.postcheck).toHaveLength(1);
611-
expect(op.postcheck[0]!.source.kind).toBe('listCollections');
612-
expect(op.postcheck[0]!.expect).toBe('exists');
610+
expect(op.postcheck).toHaveLength(0);
613611
});
614612

615613
it('classifies validator removal as widening', () => {

0 commit comments

Comments
 (0)