{"record":{"id":"457ce8406cdfca88","repo":"Automattic/mongoose","slug":"must-provide-an-update-object","errorCode":null,"errorMessage":"Must provide an update object.","messagePattern":"Must provide an update object\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/helpers/model/castBulkWrite.js","lineNumber":111,"sourceCode":"  if (versionKey && doc[versionKey] == null) {\n    doc[versionKey] = 0;\n  }\n  insertOne['document'] = doc;\n\n  if (options.skipValidation || insertOne.skipValidation) {\n    return insertOne;\n  }\n\n  await insertOne['document'].$validate();\n  return insertOne;\n};\n\nmodule.exports.castUpdateOne = function castUpdateOne(originalModel, updateOne, options, now) {\n  if (!updateOne['filter']) {\n    throw new Error('Must provide a filter object.');\n  }\n  if (!updateOne['update']) {\n    throw new Error('Must provide an update object.');\n  }\n\n  const model = decideModelByObject(originalModel, updateOne['filter']);\n  const schema = model.schema;\n  const strict = options.strict ?? model.schema.options.strict;\n\n  const update = clone(updateOne['update']);\n\n  _addDiscriminatorToObject(schema, updateOne['filter']);\n\n  const doInitTimestamps = getTimestampsOpt(updateOne, options);\n\n  if (model.schema.$timestamps != null && doInitTimestamps) {\n    const createdAt = model.schema.$timestamps.createdAt;\n    const updatedAt = model.schema.$timestamps.updatedAt;\n    applyTimestampsToUpdate(now, createdAt, updatedAt, update, {\n      timestamps: updateOne.timestamps,\n      overwriteImmutable: updateOne.overwriteImmutable","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/helpers/model/castBulkWrite.js#L93-L129","documentation":"Error \"Must provide an update object.\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/helpers/model/castBulkWrite.js:111 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}