{"record":{"id":"7e63ded44da9d34a","repo":"different-ai/openwork","slug":"ref-namespace-ref-name-is-not-available-in-c","errorCode":null,"errorMessage":"${ref.namespace}.${ref.name} is not available in CodeMode.","messagePattern":"(.+?)\\.(.+?) is not available in CodeMode\\.","errorType":"exception","errorClass":"InterpreterRuntimeError","httpStatus":null,"severity":"error","filePath":"packages/codemode/src/interpreter/runtime.ts","lineNumber":571,"sourceCode":"    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 (\n    ref.namespace === \"RegExp\" ||\n    ref.namespace === \"Map\" ||\n    ref.namespace === \"Set\" ||\n    ref.namespace === \"URLSearchParams\"\n  ) {\n    throw new InterpreterRuntimeError(`${ref.namespace}.${ref.name} is not available in CodeMode.`, node)\n  }\n  return invokeJsonMethod(ref.name, args, node)\n}\n\n// Every identifier a parameter pattern binds, used to seed TDZ slots before defaults run.\nconst collectPatternNames = (pattern: AstNode, out: Array<string> = []): Array<string> => {\n  switch (pattern.type) {\n    case \"Identifier\":\n      out.push(getString(pattern, \"name\"))\n      break\n    case \"AssignmentPattern\":\n      collectPatternNames(getNode(pattern, \"left\"), out)\n      break\n    case \"RestElement\":\n      collectPatternNames(getNode(pattern, \"argument\"), out)\n      break\n    case \"ArrayPattern\":\n      for (const element of getArray(pattern, \"elements\")) {","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/codemode/src/interpreter/runtime.ts#L553-L589","documentation":"Constructors/statics for RegExp, Map, Set, and URLSearchParams are entirely unavailable in CodeMode's global-method dispatch. invokeGlobalMethod throws this namespaced error for any method reference on those namespaces rather than attempting partial support.","triggerScenarios":"Calling RegExp.something, Map.something, Set.something, or URLSearchParams.something in CodeMode code (e.g. new-dependent patterns expressed as static calls, or Set.from-like usage).","commonSituations":"Code that manipulates query strings via URLSearchParams; dedup logic assuming Set statics; dynamic regex construction via RegExp static calls; LLM-generated code using these globals.","solutions":["Use supported alternatives: object literals as maps, array + includes for sets, string methods for parsing","Parse query strings manually with split/map over supported string methods","Do regex or URL work in a host tool call instead of inline CodeMode"],"exampleFix":"// before\nconst params = new URLSearchParams(qs).get('id');\n// after\nconst params = qs.split('&').map(p => p.split('=')).find(p => p[0] === 'id')?.[1] ?? null;","handlingStrategy":"validation","validationCode":"const bannedNamespaces = ['RegExp','Map','Set','URLSearchParams'];\nfor (const ns of bannedNamespaces) {\n  if (new RegExp(`\\\\b${ns}\\\\s*\\\\.`).test(code)) throw new Error(`${ns}.* is unavailable in CodeMode`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid RegExp/Map/Set/URLSearchParams globals in sandbox code","Use object literals, arrays, and string methods as substitutes","Delegate regex-heavy or URL parsing work to host tools","Add a pre-execution lint for banned global namespaces"],"tags":["codemode","sandbox","globals","unsupported-api"],"backgroundTag":"unsupported-api-in-sandbox","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}