{"record":{"id":"43bb7601c48c9217","repo":"xtekky/gpt4free","slug":"invalid-data-uri-image-data-uri-10","errorCode":null,"errorMessage":"Invalid data URI image. {data_uri[:10]}...","messagePattern":"Invalid data URI image\\. (.+?)\\.\\.\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"g4f/image/__init__.py","lineNumber":238,"sourceCode":"        return False\n    return True\n\n\ndef is_data_uri_an_image(data_uri: str) -> bool:\n    \"\"\"\n    Checks if the given data URI represents an image.\n\n    Args:\n        data_uri (str): The data URI to check.\n\n    Raises:\n        ValueError: If the data URI is invalid or the image format is not allowed.\n    \"\"\"\n    if data_uri.startswith(\"https:\") or data_uri.startswith(\"http:\"):\n        return True\n    # Check if the data URI starts with 'data:image' and contains an image format (e.g., jpeg, png, gif)\n    if not re.match(r\"data:image/(\\w+);base64,\", data_uri):\n        raise ValueError(f\"Invalid data URI image. {data_uri[:10]}...\")\n    # Extract the image format from the data URI\n    image_format = re.match(r\"data:image/(\\w+);base64,\", data_uri).group(1).lower()\n    # Check if the image format is one of the allowed formats (jpg, jpeg, png, gif)\n    if image_format not in EXTENSIONS_MAP and image_format != \"svg+xml\":\n        raise ValueError(\"Invalid image format (from mime file type).\")\n    return True\n\n\ndef is_accepted_format(binary_data: bytes) -> str:\n    \"\"\"\n    Checks if the given binary data represents an image with an accepted format.\n\n    Args:\n        binary_data (bytes): The binary data to check.\n\n    Raises:\n        ValueError: If the image format is not allowed.\n    \"\"\"","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/image/__init__.py#L220-L256","documentation":"Error \"Invalid data URI image. {data_uri[:10]}...\" thrown in xtekky/gpt4free.","triggerScenarios":"Thrown at g4f/image/__init__.py:238 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Provide a valid data URI starting with data:image/...;base64,...."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}