{"record":{"id":"bd16a5211c3f742e","repo":"langchain-ai/langchain","slug":"must-provide-url","errorCode":null,"errorMessage":"Must provide url.","messagePattern":"Must provide url\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/prompts/image.py","lineNumber":144,"sourceCode":"        formatted = {}\n        for k, v in self.template.items():\n            if isinstance(v, str):\n                formatted[k] = DEFAULT_FORMATTER_MAPPING[self.template_format](\n                    v, **kwargs\n                )\n            else:\n                formatted[k] = v\n        url = kwargs.get(\"url\") or formatted.get(\"url\")\n        if kwargs.get(\"path\") or formatted.get(\"path\"):\n            msg = (\n                \"Loading images from 'path' has been removed as of 0.3.15 for security \"\n                \"reasons. Please specify images by 'url'.\"\n            )\n            raise ValueError(msg)\n        detail = kwargs.get(\"detail\") or formatted.get(\"detail\")\n        if not url:\n            msg = \"Must provide url.\"\n            raise ValueError(msg)\n        if not isinstance(url, str):\n            msg = \"url must be a string.\"\n            raise ValueError(msg)  # noqa: TRY004\n        output: ImageURL = {\"url\": url}\n        if detail:\n            # Don't check literal values here: let the API check them\n            output[\"detail\"] = cast(\"Literal['auto', 'low', 'high']\", detail)\n        return output\n\n    async def aformat(self, **kwargs: Any) -> ImageURL:\n        \"\"\"Async format the prompt with the inputs.\n\n        Args:\n            **kwargs: Any arguments to be passed to the prompt template.\n\n        Returns:\n            A formatted string.\n        \"\"\"","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/prompts/image.py#L126-L162","documentation":"`ImagePromptTemplate.format()` requires a url: it takes `kwargs['url']` or the formatted `template['url']`, and if both are missing/empty it raises `ValueError('Must provide url.')`. An `ImageURL` without a url is meaningless, so the constructor of the output payload fails fast.","triggerScenarios":"Calling `format()` with no `url` kwarg while the template either has no `url` key or its `url` entry formats to an empty string; calling `format()` before setting up the url in the template.","commonSituations":"Template built with only a `detail` or placeholder key; a templated url variable whose value resolves to `''`; refactoring code where the url used to come from `path` (now blocked) and the url branch was never added.","solutions":["Pass `url=...` to `format()`.","Ensure the template contains a `url` entry (literal or variable) and that every variable is supplied so it renders non-empty.","Guard the call: skip/raise early in your own code if the resolved url is falsy."],"exampleFix":"# before\nprompt = ImagePromptTemplate(template={'detail': 'low'})\nprompt.format()  # ValueError: Must provide url.\n\n# after\nprompt = ImagePromptTemplate(input_variables=['image_url'], template={'url': '{image_url}'})\nprompt.format(image_url='https://example.com/img.png')","handlingStrategy":"validation","validationCode":"resolved_url = kwargs.get('url') or template.get('url')\nif not resolved_url:\n    raise ValueError('Image prompt needs a non-empty url before format().')\nout = prompt.format(**kwargs)","typeGuard":"def has_image_url(kwargs: dict, template: dict) -> bool:\n    return bool(kwargs.get('url') or template.get('url'))","tryCatchPattern":null,"preventionTips":["Always set a url entry (literal or variable) in the image template at construction.","Assert required variables resolve to non-empty strings before calling format."],"tags":["prompts","image","validation","multimodal"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}