{"record":{"id":"0bc46435455fffcb","repo":"different-ai/openwork","slug":"url-name-requires-a-url-argument","errorCode":null,"errorMessage":"URL.${name} requires a URL argument.","messagePattern":"URL\\.(.+?) requires a URL argument\\.","errorType":"exception","errorClass":"InterpreterRuntimeError","httpStatus":null,"severity":"error","filePath":"packages/codemode/src/stdlib/url.ts","lineNumber":73,"sourceCode":"      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\"\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/codemode/src/stdlib/url.ts#L55-L91","documentation":"URL statics in CodeMode require at least one argument (the URL to parse/test). Calling a whitelisted static with zero arguments throws this TypeError-tagged error instead of letting the host fail with a less clear message.","triggerScenarios":"`URL.canParse()` with no arguments; destructured arguments where the URL is undefined because an earlier step failed.","commonSituations":"Optional args lost when forwarding function parameters; variables accidentally shadowed to undefined.","solutions":["Pass the URL string or SandboxURL as the first argument.","Default empty input: `URL.canParse(input ?? \"\")` only when an empty-ish input is meaningful.","Fix the upstream code so the URL value is defined before the call."],"exampleFix":"// before\nURL.canParse() // missing input\n// after\nURL.canParse(input)","handlingStrategy":"validation","validationCode":"if (input === undefined || input === null) throw new TypeError(\"URL static requires an input\")","typeGuard":"const hasUrlInput = (args) => args.length > 0 && (typeof args[0] === \"string\" || args[0] != null)","tryCatchPattern":"try { ok = URL.canParse() } catch (e) { ok = false }","preventionTips":["Check argument count before forwarding to URL statics","Default-define URL variables at declaration","Avoid undefined leaking through destructured params"],"tags":["codemode","url","missing-argument","sandbox"],"backgroundTag":"missing-required-argument","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}