danny-avila/LibreChat · error · AgentRunEnvelopeError
${path}[${index}] must not be an accessor property
Error message
${path}[${index}] must not be an accessor property What it means
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.
Source
Thrown at packages/api/src/agents/envelope.ts:152
if (Array.isArray(value)) {
const cloned: unknown[] = new Array(value.length);
let clonedItemCount = 0;
for (const key of Object.getOwnPropertyNames(value)) {
if (key === 'length') {
continue;
}
const index = Number(key);
if (
!Number.isSafeInteger(index) ||
index < 0 ||
index >= value.length ||
String(index) !== key
) {
throw new AgentRunEnvelopeError(`${path} contains non-index array properties`);
}
const descriptor = Object.getOwnPropertyDescriptor(value, key);
if (!descriptor || !Object.prototype.hasOwnProperty.call(descriptor, 'value')) {
throw new AgentRunEnvelopeError(`${path}[${index}] must not be an accessor property`);
}
const itemValue: unknown = descriptor.value;
cloned[index] = cloneJsonValue(itemValue, `${path}[${index}]`, ancestors, depth + 1);
clonedItemCount++;
}
if (clonedItemCount !== value.length) {
throw new AgentRunEnvelopeError(`${path} contains sparse array entries`);
}
return cloned;
}
const prototype = Object.getPrototypeOf(value);
if (prototype !== Object.prototype && prototype !== null) {
const typeName = value.constructor?.name ?? 'object';
throw new AgentRunEnvelopeError(`${path} contains a non-plain ${typeName} value`);
}
const cloned: { [key: string]: unknown } = {};View on GitHub (pinned to 5ff282f900)
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.
Example fix
// before
Object.defineProperty(results, 0, { get: () => compute(), enumerable: true });
createAgentRunEnvelope({ protocol, requestId, receivedAt, principal, payload: { results } });
// after
const results = [compute()];
createAgentRunEnvelope({ protocol, requestId, receivedAt, principal, payload: { results } }); Defensive patterns
Strategy: validation
Validate before calling
function arrayHasOnlyDataValues(arr: unknown[]): boolean {
for (const key of Object.getOwnPropertyNames(arr)) {
if (key === 'length') continue;
const d = Object.getOwnPropertyDescriptor(arr, key);
if (!d || !Object.prototype.hasOwnProperty.call(d, 'value')) return false;
}
return true;
}
if (Array.isArray(payload.results) && !arrayHasOnlyDataValues(payload.results)) {
payload.results = payload.results.map((x) => x); // materialize getters into data values
} Type guard
function isArrayDataValues(arr: unknown[]): boolean {
return Object.getOwnPropertyNames(arr)
.filter((k) => k !== 'length')
.every((k) => {
const d = Object.getOwnPropertyDescriptor(arr, k);
return !!d && Object.prototype.hasOwnProperty.call(d, 'value');
});
} Try / catch
try {
const env = createAgentRunEnvelope(input);
} catch (e) {
if (e instanceof AgentRunEnvelopeError && /accessor property/.test(e.message)) {
// materialize: payload = JSON.parse(JSON.stringify(payload));
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- ${path} contains non-index array properties
- ${path} contains sparse array entries
- ${path}.${key} must not be an accessor property
- ${path} contains a non-JSON ${typeof value} value
- ${path} contains a circular reference
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/ef4a995d0a10bb3d.
Report an issue: GitHub.