{"record":{"id":"9e49c21fcaf7322a","repo":"BerriAI/litellm","slug":"invalid-data-url-format-missing-comma-data-url","errorCode":null,"errorMessage":"Invalid data URL format (missing comma): {data_url[:50]}...","messagePattern":"Invalid data URL format \\(missing comma\\): (.+?)\\.\\.\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/embed/amazon_nova_transformation.py","lineNumber":71,"sourceCode":"    def _parse_data_url(self, data_url: str) -> tuple:\n        \"\"\"\n        Parse a data URL to extract the media type and base64 data.\n\n        Args:\n            data_url: Data URL in format: data:image/jpeg;base64,/9j/4AAQ...\n\n        Returns:\n            tuple: (media_type, base64_data)\n                media_type: e.g., \"image/jpeg\", \"video/mp4\", \"audio/mpeg\"\n                base64_data: The base64-encoded data without the prefix\n        \"\"\"\n        if not data_url.startswith(\"data:\"):\n            raise ValueError(f\"Invalid data URL format: {data_url[:50]}...\")\n\n        # Split by comma to separate metadata from data\n        # Format: data:image/jpeg;base64,<base64_data>\n        if \",\" not in data_url:\n            raise ValueError(f\"Invalid data URL format (missing comma): {data_url[:50]}...\")\n\n        metadata, base64_data = data_url.split(\",\", 1)\n\n        # Extract media type from metadata\n        # Remove 'data:' prefix and ';base64' suffix\n        metadata = metadata[5:]  # Remove 'data:'\n\n        if \";\" in metadata:\n            media_type = metadata.split(\";\")[0]\n        else:\n            media_type = metadata\n\n        return media_type, base64_data\n\n    def _transform_request(\n        self,\n        input: str,\n        inference_params: dict,","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/embed/amazon_nova_transformation.py#L53-L89","documentation":"Raised by AmazonNovaEmbeddingConfig._parse_data_url when the value starts with 'data:' but contains no comma. The RFC 2397 format separates metadata ('data:image/jpeg;base64') from the payload with a single comma; without it the parser cannot split media type from base64 data.","triggerScenarios":"Sending 'data:image/jpeg;base64' (header with the payload forgotten); truncation/copy-paste that cut the string at the comma; URL-encoding the whole data URL so the comma became %2C; building the string with a missing format placeholder ('data:{};base64,{}' called with one arg).","commonSituations":"f-string templates with wrong arity; log/secret redaction tools stripping everything after commas; passing encoded URLs from web frameworks that percent-encode automatically.","solutions":["Ensure the full form data:<mime>;base64,<payload> including the comma","Unquote the value first if it may be percent-encoded: urllib.parse.unquote(data_url)","Guard length: after the comma there should be non-empty base64 payload"],"exampleFix":"# before\nmedia = 'data:image/jpeg;base64'  # payload missing\n\n# after\nmedia = 'data:image/jpeg;base64,/9j/4AAQSkZJRg=='","handlingStrategy":"validation","validationCode":"def assert_wellformed_data_url(u: str) -> None:\n    if not u.startswith('data:'):\n        raise ValueError('missing data: prefix')\n    if ',' not in u:\n        raise ValueError('missing comma between metadata and payload')\n    meta, payload = u.split(',', 1)\n    if not payload:\n        raise ValueError('empty base64 payload after comma')","typeGuard":"from typing import TypeGuard\n\ndef is_valid_data_url(u: object) -> TypeGuard[str]:\n    if not isinstance(u, str):\n        return False\n    return u.startswith('data:') and ',' in u and u.split(',', 1)[1] != ''","tryCatchPattern":"try:\n    resp = litellm.embedding(model='bedrock/amazon.nova-embed-v1', input=[url])\nexcept ValueError as e:\n    if 'missing comma' in str(e):\n        raise InputTruncatedError(f'data URL payload missing after header: {url[:50]}') from e\n    raise","preventionTips":["Unquote percent-encoded values (urllib.parse.unquote) before passing","Beware redaction/templating tools that cut strings at commas","Add a length assertion: data URLs are typically far longer than the header"],"tags":["bedrock","nova","embedding","data-url","malformed-input"],"backgroundTag":"invalid-data-url","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}