{"record":{"id":"ef4a995d0a10bb3d","repo":"danny-avila/LibreChat","slug":"path-index-must-not-be-an-accessor-property","errorCode":null,"errorMessage":"${path}[${index}] must not be an accessor property","messagePattern":"(.+?)\\[(.+?)\\] must not be an accessor property","errorType":"validation","errorClass":"AgentRunEnvelopeError","httpStatus":null,"severity":"error","filePath":"packages/api/src/agents/envelope.ts","lineNumber":152,"sourceCode":"    if (Array.isArray(value)) {\n      const cloned: unknown[] = new Array(value.length);\n      let clonedItemCount = 0;\n      for (const key of Object.getOwnPropertyNames(value)) {\n        if (key === 'length') {\n          continue;\n        }\n        const index = Number(key);\n        if (\n          !Number.isSafeInteger(index) ||\n          index < 0 ||\n          index >= value.length ||\n          String(index) !== key\n        ) {\n          throw new AgentRunEnvelopeError(`${path} contains non-index array properties`);\n        }\n        const descriptor = Object.getOwnPropertyDescriptor(value, key);\n        if (!descriptor || !Object.prototype.hasOwnProperty.call(descriptor, 'value')) {\n          throw new AgentRunEnvelopeError(`${path}[${index}] must not be an accessor property`);\n        }\n        const itemValue: unknown = descriptor.value;\n        cloned[index] = cloneJsonValue(itemValue, `${path}[${index}]`, ancestors, depth + 1);\n        clonedItemCount++;\n      }\n      if (clonedItemCount !== value.length) {\n        throw new AgentRunEnvelopeError(`${path} contains sparse array entries`);\n      }\n      return cloned;\n    }\n\n    const prototype = Object.getPrototypeOf(value);\n    if (prototype !== Object.prototype && prototype !== null) {\n      const typeName = value.constructor?.name ?? 'object';\n      throw new AgentRunEnvelopeError(`${path} contains a non-plain ${typeName} value`);\n    }\n\n    const cloned: { [key: string]: unknown } = {};","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/packages/api/src/agents/envelope.ts#L134-L170","documentation":"Thrown by cloneJsonValue when an array index property is defined by a getter/setter (accessor) rather than a plain data value. The check is Object.getOwnPropertyDescriptor lacking an own 'value' key. Accessors can execute arbitrary code or throw on read, so the envelope clone refuses to invoke them; it requires a concrete value it can copy safely.","triggerScenarios":"An array built with Object.defineProperty(arr, 0, { get() {...} }) or an array subclass whose indices are virtualized. Proxy-wrapped arrays whose traps surface as accessors can also reach this.","commonSituations":"A custom collection class extending Array that virtualizes elements; sealing/freezing with accessor descriptors; interop with libraries that wrap arrays in getters for lazy loading.","solutions":["Materialize the array into a plain Array of concrete values via Array.from(arr) or arr.map(x => x) before passing it in.","Replace accessor-defined indices with normal assignments (arr[0] = value).","Avoid extending Array for payload objects; use composition instead."],"exampleFix":"// before\nObject.defineProperty(results, 0, { get: () => compute(), enumerable: true });\ncreateAgentRunEnvelope({ protocol, requestId, receivedAt, principal, payload: { results } });\n\n// after\nconst results = [compute()];\ncreateAgentRunEnvelope({ protocol, requestId, receivedAt, principal, payload: { results } });","handlingStrategy":"validation","validationCode":"function arrayHasOnlyDataValues(arr: unknown[]): boolean {\n  for (const key of Object.getOwnPropertyNames(arr)) {\n    if (key === 'length') continue;\n    const d = Object.getOwnPropertyDescriptor(arr, key);\n    if (!d || !Object.prototype.hasOwnProperty.call(d, 'value')) return false;\n  }\n  return true;\n}\nif (Array.isArray(payload.results) && !arrayHasOnlyDataValues(payload.results)) {\n  payload.results = payload.results.map((x) => x); // materialize getters into data values\n}","typeGuard":"function isArrayDataValues(arr: unknown[]): boolean {\n  return Object.getOwnPropertyNames(arr)\n    .filter((k) => k !== 'length')\n    .every((k) => {\n      const d = Object.getOwnPropertyDescriptor(arr, k);\n      return !!d && Object.prototype.hasOwnProperty.call(d, 'value');\n    });\n}","tryCatchPattern":"try {\n  const env = createAgentRunEnvelope(input);\n} catch (e) {\n  if (e instanceof AgentRunEnvelopeError && /accessor property/.test(e.message)) {\n    // materialize: payload = JSON.parse(JSON.stringify(payload));\n  } else throw e;\n}","preventionTips":["Avoid Object.defineProperty on array indices; assign directly (arr[i] = v).","Do not extend Array for values placed in the payload.","Materialize arrays via .map(x => x) or Array.from before sending."],"tags":["serialization","json","array","accessor-property","agent-envelope"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}