Skip to content

Commit 54bab0e

Browse files
committed
TML-2839: prevent factory output from overriding bound scaffold fields in mongo buildBoundContract
Spread only the factory's declared outputs (models/valueObjects/roots) via ifDefined instead of the whole factory return, so a factory cannot clobber the pre-bound family/target/extensionPacks. Follow-up to the CodeRabbit finding on #730 (TML-2817), which merged before it was addressed. Signed-off-by: Will Madden <madden@prisma.io>
1 parent fa181e3 commit 54bab0e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/2-mongo-family/2-authoring/contract-ts/src/contract-builder.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1721,7 +1721,13 @@ export function buildBoundContract<
17211721
rel,
17221722
valueObject,
17231723
} as unknown as ContractAuthoringHelpers<F, T, NonNullable<Definition['extensionPacks']>>;
1724-
return buildContractFromDefinition({ ...full, ...factory(helpers) });
1724+
const built = factory(helpers);
1725+
return buildContractFromDefinition({
1726+
...full,
1727+
...ifDefined('models', built.models),
1728+
...ifDefined('valueObjects', built.valueObjects),
1729+
...ifDefined('roots', built.roots),
1730+
});
17251731
}
17261732

17271733
return buildContractFromDefinition(full);

0 commit comments

Comments
 (0)