{"record":{"id":"4ba719c6426761d3","repo":"hcengineering/platform","slug":"core-status-objectnotfound-4ba719","errorCode":"core.status.ObjectNotFound","errorMessage":"ObjectNotFound","messagePattern":"ObjectNotFound","errorType":"error_code","errorClass":"PlatformError","httpStatus":null,"severity":"error","filePath":"foundations/core/packages/core/src/objvalue.ts","lineNumber":53,"sourceCode":" */\nexport function setObjectValue (key: string, doc: Doc, newValue: any): void {\n  // Check dot notation\n  if (key.length === 0) {\n    return\n  }\n  key = key.split('\\\\$').join('$')\n  let dots = key.split('.')\n  // Replace escapting, since memdb is not escape keys\n\n  const last = dots[dots.length - 1]\n  dots = dots.slice(0, -1)\n\n  // We have dots, so iterate in depth\n  let value = doc as any\n  for (const d of dots) {\n    if (Array.isArray(value) && isNestedArrayQuery(value, d)) {\n      // Arrays are not supported\n      throw new PlatformError(new Status(Severity.ERROR, core.status.ObjectNotFound, { _id: 'dots' }))\n    }\n    const lvalue = value?.[d]\n    if (lvalue === undefined) {\n      value[d] = {}\n      value = value?.[d]\n    } else {\n      value = lvalue\n    }\n  }\n  value[last] = clone(newValue)\n  return value\n}\n\nfunction isNestedArrayQuery (value: any, d: string): boolean {\n  return Number.isNaN(Number.parseInt(d)) && value?.[d as any] === undefined\n}\n\nfunction getNestedArrayValue (value: any[], name: string): any[] {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/core/packages/core/src/objvalue.ts#L35-L71","documentation":"setObjectValue builds nested intermediate objects when applying a dotted-path update. When the path traverses an array (dots present) it cannot safely create nested values inside arrays, so it throws a PlatformError with core.status.ObjectNotFound and _id:'dots' to signal 'arrays are not supported' for this update path.","triggerScenarios":"Calling setObjectValue (via applyUpdate or updateMixin4Doc) with a patch key containing dots that resolves into an array element, e.g. 'items.0.name' or 'tags.x' where tags is an array and isNestedArrayQuery matches.","commonSituations":"UI forms generating dotted paths over array fields; migrating updates written for a plain object schema while the attribute was changed to an array; mixin updates addressing array-of-objects properties.","solutions":["Restructure the update to replace the whole array field instead of addressing elements by dotted path","Load the doc, mutate the array in code, and update via a non-dotted patch","Change the data model so the nested collection is a separate AttachedDoc rather than an embedded array","Catch this status code and surface a clear 'array updates not supported' message"],"exampleFix":"// before\nawait applyUpdate(doc._id, doc._class, { 'items.0.done': true })\n// after\nconst items = (doc.items ?? []).map((it, i) => i === 0 ? { ...it, done: true } : it)\nawait applyUpdate(doc._id, doc._class, { items })","handlingStrategy":"validation","validationCode":"const key = 'items.0.done'\nconst root = key.split('.')[0]\nconst probe = (doc as any)[root]\nif (Array.isArray(probe)) {\n  throw new Error(`Dotted update '${key}' targets an array; replace the whole field instead`)\n}\nawait applyUpdate(doc._id, doc._class, { [key]: value })","typeGuard":null,"tryCatchPattern":"try {\n  await applyUpdate(_id, _class, patch)\n} catch (err: any) {\n  if (err?.status?.code === core.status.ObjectNotFound && err?.status?.params?._id === 'dots') {\n    // array update rejected - fallback to whole-field replacement\n    return applyWholeFieldUpdate(_id, _class, patch)\n  }\n  throw err\n}","preventionTips":["Avoid dotted paths that traverse arrays; update the array field wholesale","Model nested collections as AttachedDoc relations instead of embedded arrays","Sanitize incoming patch keys against the class attribute types","Test update paths against real document shapes in CI"],"tags":["update","dotted-path","arrays-unsupported"],"backgroundTag":"unsupported-array-update","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}