different-ai/openwork · error · InterpreterRuntimeError
URL.${name} requires a URL argument.
Error message
URL.${name} requires a URL argument. What it means
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.
Source
Thrown at packages/codemode/src/stdlib/url.ts:73
case "decodeURI":
return decodeURI(value)
case "decodeURIComponent":
return decodeURIComponent(value)
}
} catch (error) {
throw new InterpreterRuntimeError(
`${ref.name} received malformed URI data: ${error instanceof Error ? error.message : String(error)}`,
node,
).as("URIError")
}
}
export const urlArgument = (value: unknown, label: string): string =>
value instanceof SandboxURL ? value.url.href : uriArgument(value, label)
export const invokeURLStatic = (name: string, args: Array<unknown>, node: AstNode): unknown => {
if (!urlStatics.has(name)) throw new InterpreterRuntimeError(`URL.${name} is not available in CodeMode.`, node)
if (args.length === 0) throw new InterpreterRuntimeError(`URL.${name} requires a URL argument.`, node).as("TypeError")
const input = urlArgument(args[0], `URL.${name} input`)
const base = args[1] === undefined ? undefined : urlArgument(args[1], `URL.${name} base`)
try {
const url = new URL(input, base)
return name === "canParse" ? true : new SandboxURL(url)
} catch {
return name === "canParse" ? false : null
}
}
export const invokeURLMethod = (value: SandboxURL, name: string, node: AstNode): string => {
if (name === "toString" || name === "toJSON") return value.url.href
throw new InterpreterRuntimeError(`URL method '${name}' is not available in CodeMode.`, node)
}
import { type AstNode, InterpreterRuntimeError, UriFunction } from "../interpreter/model.js"
import { SandboxURL } from "../values.js"
import { boundedData, coerceToString } from "./value.js"
View on GitHub (pinned to 2b7df46e8a)
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.
Example fix
// before URL.canParse() // missing input // after URL.canParse(input)
Defensive patterns
Strategy: validation
Validate before calling
if (input === undefined || input === null) throw new TypeError("URL static requires an input") Type guard
const hasUrlInput = (args) => args.length > 0 && (typeof args[0] === "string" || args[0] != null)
Try / catch
try { ok = URL.canParse() } catch (e) { ok = false } Prevention
- Check argument count before forwarding to URL statics
- Default-define URL variables at declaration
- Avoid undefined leaking through destructured params
When it happens
Trigger: `URL.canParse()` with no arguments; destructured arguments where the URL is undefined because an earlier step failed.
Common situations: Optional args lost when forwarding function parameters; variables accidentally shadowed to undefined.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- URL.${name} is not available in CodeMode.
- URL method '${name}' is not available in CodeMode.
- String method '${name}' is not available in CodeMode.
- Array.from(...) does not support a map function in CodeMode;
- Array.from expects an array, string, Map, Set, or array-like
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/0bc46435455fffcb.
Report an issue: GitHub.