{"record":{"id":"9dc576cce87753e2","repo":"different-ai/openwork","slug":"array-name-is-not-available-in-codemode","errorCode":null,"errorMessage":"Array.${name} is not available in CodeMode.","messagePattern":"Array\\.(.+?) is not available in CodeMode\\.","errorType":"exception","errorClass":"InterpreterRuntimeError","httpStatus":null,"severity":"error","filePath":"packages/codemode/src/interpreter/runtime.ts","lineNumber":547,"sourceCode":"        return Array.from((args[0] as SandboxMap).map.entries(), ([key, item]) => [key, item])\n      if (args[0] instanceof SandboxSet) return Array.from((args[0] as SandboxSet).set.values())\n      if (args[0] instanceof SandboxURLSearchParams) {\n        return Array.from(args[0].params.entries(), ([key, value]) => [key, value])\n      }\n      const source = boundedData(args[0], \"Array.from input\")\n      if (typeof source === \"string\") return Array.from(source)\n      if (Array.isArray(source)) return [...source]\n      if (\n        source !== null &&\n        typeof source === \"object\" &&\n        typeof (source as { length?: unknown }).length === \"number\"\n      ) {\n        return Array.from(source as ArrayLike<unknown>)\n      }\n      throw new InterpreterRuntimeError(\"Array.from expects an array, string, Map, Set, or array-like value.\", node)\n    }\n    default:\n      throw new InterpreterRuntimeError(`Array.${name} is not available in CodeMode.`, node)\n  }\n}\n\nconst invokeGlobalMethod = (ref: GlobalMethodReference, args: Array<unknown>, node: AstNode): unknown => {\n  if (ref.namespace === \"console\")\n    throw new InterpreterRuntimeError(`console.${ref.name} is not available in CodeMode.`, node)\n  if (ref.namespace === \"Object\") return invokeObjectMethod(ref.name, args, node)\n  if (ref.namespace === \"Math\") return invokeMathMethod(ref.name, args, node)\n  if (ref.namespace === \"Array\") return invokeArrayStatic(ref.name, args, node)\n  if (ref.namespace === \"Number\") return invokeNumberStatic(ref.name, args, node)\n  if (ref.namespace === \"String\") return invokeStringStatic(ref.name, args, node)\n  if (ref.namespace === \"URL\") return invokeURLStatic(ref.name, args, node)\n  if (ref.namespace === \"Date\") {\n    if (!dateStatics.has(ref.name))\n      throw new InterpreterRuntimeError(`Date.${ref.name} is not available in CodeMode.`, node)\n    return invokeDateStatic(ref.name, args, node)\n  }\n  if (","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/codemode/src/interpreter/runtime.ts#L529-L565","documentation":"Only a fixed set of Array statics (isArray, of, from) is implemented in invokeArrayStatic. Any other Array.* static call hits the default branch and throws this error. The sandbox intentionally exposes a minimal, deterministic API surface.","triggerScenarios":"Calling unsupported Array statics inside CodeMode such as Array.fromAsync, Array.prototype-flavored statics like Array.flat (mistaken), or hypothetical Array.zip/pair helpers; any Array.<name> not matching isArray/of/from.","commonSituations":"Using newer or exotic Array statics; typos like Array.form instead of Array.from (hits default branch); assuming Node's full global Array surface exists in the sandbox.","solutions":["Restrict to Array.isArray, Array.of, and single-argument Array.from","Fix typos (Array.form -> Array.from)","Implement missing helpers manually with supported syntax (loops, spread)","Perform unsupported operations via a tool call instead of inline CodeMode"],"exampleFix":"// before\nconst filled = Array.from({length: 3}, () => 0); // also rejected\nconst isArr = Array.instanceOf(x); // not a real API -> throws\n// after\nconst isArr = Array.isArray(x);","handlingStrategy":"try-catch","validationCode":"const supportedArrayStatics = ['isArray','of','from'];\nif (/Array\\.[A-Za-z_$][\\w$]*\\s*\\(/.test(code)) {\n  for (const m of code.matchAll(/Array\\.([A-Za-z_$][\\w$]*)\\s*\\(/g)) {\n    if (!supportedArrayStatics.includes(m[1])) throw new Error(`Array.${m[1]} unsupported in CodeMode`);\n  }\n}","typeGuard":"function arrayStaticSupported(name) { return ['isArray','of','from'].includes(name); }","tryCatchPattern":"try {\n  result = invokeCodeMode(code);\n} catch (e) {\n  if (String(e.message).startsWith('Array.')) {\n    // fall back to a host-side implementation of the static\n  } else throw e;\n}","preventionTips":["Limit Array usage to isArray/of/from inside sandbox code","Check for typos like Array.form","Move exotic array statics into host-side tools"],"tags":["codemode","sandbox","array-statics","unsupported-api"],"backgroundTag":"unsupported-api-in-sandbox","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}