{"record":{"id":"42e3a26b2d078222","repo":"microsoft/autogen","slug":"invalid-uri-format-it-should-be-a-base64-encoded","errorCode":null,"errorMessage":"Invalid URI format. It should be a base64 encoded image URI.","messagePattern":"Invalid URI format\\. It should be a base64 encoded image URI\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-core/src/autogen_core/_image.py","lineNumber":52,"sourceCode":"                        content = await response.read()\n                        return Image.from_pil(PILImage.open(content))\n\n\n            image = asyncio.run(from_url(\"https://example.com/image\"))\n\n    \"\"\"\n\n    def __init__(self, image: PILImage.Image):\n        self.image: PILImage.Image = image.convert(\"RGB\")\n\n    @classmethod\n    def from_pil(cls, pil_image: PILImage.Image) -> Image:\n        return cls(pil_image)\n\n    @classmethod\n    def from_uri(cls, uri: str) -> Image:\n        if not re.match(r\"data:image/(?:png|jpeg);base64,\", uri):\n            raise ValueError(\"Invalid URI format. It should be a base64 encoded image URI.\")\n\n        # A URI. Remove the prefix and decode the base64 string.\n        base64_data = re.sub(r\"data:image/(?:png|jpeg);base64,\", \"\", uri)\n        return cls.from_base64(base64_data)\n\n    @classmethod\n    def from_base64(cls, base64_str: str) -> Image:\n        return cls(PILImage.open(BytesIO(base64.b64decode(base64_str))))\n\n    def to_base64(self) -> str:\n        buffered = BytesIO()\n        self.image.save(buffered, format=\"PNG\")\n        content = buffered.getvalue()\n        return base64.b64encode(content).decode(\"utf-8\")\n\n    @classmethod\n    def from_file(cls, file_path: Path) -> Image:\n        return cls(PILImage.open(file_path))","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-core/src/autogen_core/_image.py#L34-L70","documentation":"Error \"Invalid URI format. It should be a base64 encoded image URI.\" thrown in microsoft/autogen.","triggerScenarios":"Thrown at python/packages/autogen-core/src/autogen_core/_image.py:52 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use data:<mediatype>;base64,<data> format"],"exampleFix":"Image.from_uri('data:image/png;base64,...')","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}