You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A Mongo field whose codec is unknown makes every write to its collection fail validation #30460
What a user sees. When a Mongo PSL contract names a codec the codec lookup does not know (for example an extension codec whose pack is missing from the config), contract emit succeeds and the field is left out of the collection's $jsonSchema validator. The validator is closed with additionalProperties: false, so every document that carries the field is then rejected by MongoDB with Document failed validation, at write time, with no mention of the codec.
Where.fieldToBsonSchema in packages/2-mongo-family/2-authoring/contract-psl/src/derive-json-schema.ts returns undefined when codecLookup.targetTypesFor(codecId) is undefined, and the caller drops the property.
Likely fix. Report an unknown codec id as an authoring error during contract emit, naming the model, the field and the codec id, instead of emitting a validator that rejects the field. If there is a case where an unknown codec must be allowed, emit {} for the field so the validator does not reject it.
Where it came from. Pre-existing behaviour, recorded during #30396.
Activity