{"record":{"id":"3d37a6229387bfb4","repo":"different-ai/openwork","slug":"date-ref-name-is-not-available-in-codemode","errorCode":null,"errorMessage":"Date.${ref.name} is not available in CodeMode.","messagePattern":"Date\\.(.+?) is not available in CodeMode\\.","errorType":"exception","errorClass":"InterpreterRuntimeError","httpStatus":null,"severity":"error","filePath":"packages/codemode/src/interpreter/runtime.ts","lineNumber":562,"sourceCode":"      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 (\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\"))","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/codemode/src/interpreter/runtime.ts#L544-L580","documentation":"CodeMode exposes only a whitelist of Date statics (dateStatics). Any Date.<name> reference not present in that set is rejected before invokeDateStatic runs. This prevents use of statics the interpreter has not validated for determinism or safety.","triggerScenarios":"Calling unsupported Date statics such as Date.now() (if not whitelisted), Date.parse, Date.UTC, or mistyped names like date.now; dispatched from invokeGlobalMethod when namespace === 'Date'.","commonSituations":"Timestamping work inside sandboxed code expecting Date.now(); parsing date strings with Date.parse; assuming full Date API parity with standard JS.","solutions":["Check dateStatics in the runtime for supported Date statics and use only those","Pass timestamps in as arguments from the host instead of computing Date.now() inside the code","Do date parsing/formatting outside CodeMode and feed results in"],"exampleFix":"// before\nconst ts = Date.now();\n// after\n// host passes timestamp as an input parameter\nconst ts = now; // `now` provided by the caller","handlingStrategy":"validation","validationCode":"const supportedDateStatics = ['now','parse','UTC']; // verify against dateStatics in runtime\nfor (const m of code.matchAll(/Date\\.([A-Za-z_$][\\w$]*)/g)) {\n  if (!supportedDateStatics.includes(m[1])) throw new Error(`Date.${m[1]} unsupported in CodeMode`);\n}","typeGuard":"function dateStaticSupported(name, whitelist) { return whitelist.has(name); }","tryCatchPattern":null,"preventionTips":["Check dateStatics in the runtime before using Date.*","Pass timestamps as inputs from the host rather than calling Date.now() in code","Do complex date parsing outside the sandbox"],"tags":["codemode","sandbox","date","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"}