{"record":{"id":"581ad2cd786c47e8","repo":"OpenBMB/ChatDev","slug":"package-names-cannot-be-empty","errorCode":null,"errorMessage":"package names cannot be empty","messagePattern":"package names cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"functions/function_calling/uv_related.py","lineNumber":71,"sourceCode":"        return path\n\n    def resolve_under_workspace(self, relative_path: str | Path) -> Path:\n        candidate = Path(relative_path)\n        absolute = candidate if candidate.is_absolute() else self.workspace_root / candidate\n        absolute = absolute.expanduser().resolve()\n        if self.workspace_root not in absolute.parents and absolute != self.workspace_root:\n            raise ValueError(\"script path is outside workspace root\")\n        return absolute\n\n\ndef _validate_packages(packages: Sequence[str]) -> List[str]:\n    normalized: List[str] = []\n    for pkg in packages:\n        if not isinstance(pkg, str):\n            raise ValueError(\"package entries must be strings\")\n        stripped = pkg.strip()\n        if not stripped:\n            raise ValueError(\"package names cannot be empty\")\n        if not _SAFE_PACKAGE_RE.match(stripped):\n            raise ValueError(f\"unsafe characters detected in package spec {pkg}\")\n        if stripped.startswith(\"-\"):\n            raise ValueError(f\"flags are not allowed in packages list: {pkg}\")\n        normalized.append(stripped)\n    if not normalized:\n        raise ValueError(\"at least one package is required\")\n    return normalized\n\n\ndef _coerce_timeout_seconds(timeout_seconds: Any) -> float | None:\n    if timeout_seconds is None:\n        return None\n    if isinstance(timeout_seconds, bool):\n        raise ValueError(\"timeout_seconds must be a number\")\n    if isinstance(timeout_seconds, (int, float)):\n        value = float(timeout_seconds)\n    elif isinstance(timeout_seconds, str):","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/functions/function_calling/uv_related.py#L53-L89","documentation":"Each package spec is stripped of whitespace and must be non-empty; empty strings or whitespace-only entries raise ValueError. This catches degenerate list entries like \"\" or \"   \" that would otherwise produce a broken uv command line.","triggerScenarios":"Passing packages=[\"\", \"numpy\"] or packages=[\"  \"]; strings built from empty variables or split of an empty string (\"\".split() vs \"\".split(\",\")); trailing commas producing empty fields (\"numpy,\".split(\",\")).","commonSituations":"Splitting a comma-separated user input with trailing/double commas; config defaults of empty string; form fields left blank but included in the list.","solutions":["Filter empties before calling: [p for p in packages if p and p.strip()]","Fix the splitting logic to drop empty fields (e.g. [x for x in raw.split(\",\") if x.strip()])","Validate against a schema with minLength on package entries"],"exampleFix":"# before\ninstall_python_packages(packages=\"numpy,,pandas\".split(\",\"))\n# after\ninstall_python_packages(packages=[p for p in \"numpy,,pandas\".split(\",\") if p.strip()])","handlingStrategy":"validation","validationCode":"packages = [p.strip() for p in packages if isinstance(p, str) and p.strip()]\nif not packages:\n    raise ValueError(\"no packages requested\")\ninstall_python_packages(packages=packages, _context=ctx)","typeGuard":"def no_empty_entries(packages) -> bool:\n    return all(isinstance(p, str) and p.strip() for p in packages)","tryCatchPattern":"try:\n    install_python_packages(packages=packages, _context=ctx)\nexcept ValueError as e:\n    if \"cannot be empty\" in str(e):\n        packages = [p for p in packages if p and p.strip()]\n        install_python_packages(packages=packages, _context=ctx)\n    else:\n        raise","preventionTips":["Filter empty fields when splitting comma-separated input","Drop blank form fields before assembling the list","Use schema minLength: 1 on array items"],"tags":["validation","uv","packages","empty-string"],"backgroundTag":"empty-string-argument","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}