{"record":{"id":"b761d118f5732a44","repo":"different-ai/openwork","slug":"url-name-is-not-available-in-codemode","errorCode":null,"errorMessage":"URL.${name} is not available in CodeMode.","messagePattern":"URL\\.(.+?) is not available in CodeMode\\.","errorType":"exception","errorClass":"InterpreterRuntimeError","httpStatus":null,"severity":"error","filePath":"packages/codemode/src/stdlib/url.ts","lineNumber":72,"sourceCode":"        return encodeURIComponent(value)\n      case \"decodeURI\":\n        return decodeURI(value)\n      case \"decodeURIComponent\":\n        return decodeURIComponent(value)\n    }\n  } catch (error) {\n    throw new InterpreterRuntimeError(\n      `${ref.name} received malformed URI data: ${error instanceof Error ? error.message : String(error)}`,\n      node,\n    ).as(\"URIError\")\n  }\n}\n\nexport const urlArgument = (value: unknown, label: string): string =>\n  value instanceof SandboxURL ? value.url.href : uriArgument(value, label)\n\nexport const invokeURLStatic = (name: string, args: Array<unknown>, node: AstNode): unknown => {\n  if (!urlStatics.has(name)) throw new InterpreterRuntimeError(`URL.${name} is not available in CodeMode.`, node)\n  if (args.length === 0) throw new InterpreterRuntimeError(`URL.${name} requires a URL argument.`, node).as(\"TypeError\")\n  const input = urlArgument(args[0], `URL.${name} input`)\n  const base = args[1] === undefined ? undefined : urlArgument(args[1], `URL.${name} base`)\n  try {\n    const url = new URL(input, base)\n    return name === \"canParse\" ? true : new SandboxURL(url)\n  } catch {\n    return name === \"canParse\" ? false : null\n  }\n}\n\nexport const invokeURLMethod = (value: SandboxURL, name: string, node: AstNode): string => {\n  if (name === \"toString\" || name === \"toJSON\") return value.url.href\n  throw new InterpreterRuntimeError(`URL method '${name}' is not available in CodeMode.`, node)\n}\nimport { type AstNode, InterpreterRuntimeError, UriFunction } from \"../interpreter/model.js\"\nimport { SandboxURL } from \"../values.js\"\nimport { boundedData, coerceToString } from \"./value.js\"","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/codemode/src/stdlib/url.ts#L54-L90","documentation":"CodeMode whitelists a small set of URL statics (e.g. canParse, parse-like helpers). Calling a URL static outside that whitelist is rejected before any argument evaluation, keeping the sandbox surface explicit.","triggerScenarios":"`URL.createObjectURL(...)`, `URL.revokeObjectURL(...)`, or any static not in urlStatics, invoked inside CodeMode.","commonSituations":"Porting browser code that uses object URLs into the sandbox; assuming all WHATWG URL statics exist in CodeMode.","solutions":["Use only whitelisted statics (e.g. URL.canParse).","Create the URL via the sandbox's URL constructor path and use its properties.","Handle blobs/object-URL workflows outside CodeMode, in the host."],"exampleFix":"// before\nconst u = URL.createObjectURL(blob)\n// after\nconst ok = URL.canParse(candidateHref)\nconst u = ok ? new SandboxURL(candidateHref) : null","handlingStrategy":"validation","validationCode":"const urlStatics = new Set([\"canParse\"])\nif (!urlStatics.has(name)) throw new TypeError(`URL.${name} unsupported in CodeMode`)","typeGuard":"const isAllowedURLStatic = (name) => urlStatics.has(name)","tryCatchPattern":"try { u = URL.createObjectURL(b) } catch { u = null /* do it in host instead */ }","preventionTips":["Use only whitelisted URL statics in sandbox code","Move blob/object-URL workflows to the host","Gate sandbox scripts with an API-usage checklist"],"tags":["codemode","url","sandbox","unsupported-api"],"backgroundTag":"api-not-available-in-sandbox","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}