{"record":{"id":"cbe28c82586adeaf","repo":"3b1b/manim","slug":"must-specify-either-a-file-name-or-svg-string-svgm","errorCode":null,"errorMessage":"Must specify either a file_name or svg_string SVGMobject","messagePattern":"Must specify either a file_name or svg_string SVGMobject","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"manimlib/mobject/svg/svg_mobject.py","lineNumber":97,"sourceCode":"            color=None,\n            opacity=None,\n            fill_color=None,\n            fill_opacity=None,\n            stroke_width=None,\n            stroke_color=None,\n            stroke_opacity=None,\n        ),\n        path_string_config: dict = dict(),\n        **kwargs\n    ):\n        if svg_string != \"\":\n            self.svg_string = svg_string\n        elif file_name != \"\":\n            self.svg_string = self.file_name_to_svg_string(file_name)\n        elif self.file_name != \"\":\n            self.svg_string = self.file_name_to_svg_string(self.file_name)\n        else:\n            raise Exception(\"Must specify either a file_name or svg_string SVGMobject\")\n\n        self.svg_default = dict(svg_default)\n        self.path_string_config = dict(path_string_config)\n\n        super().__init__(**kwargs)\n        self.init_svg_mobject()\n        self.ensure_positive_orientation()\n\n        # Initialize position\n        height = height or self.height\n        width = width or self.width\n\n        initial_height = self.get_height()\n\n        if should_center:\n            self.center()\n        if height is not None:\n            self.set_height(height)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/mobject/svg/svg_mobject.py#L79-L115","documentation":"Raised by SVGMobject.__init__ (svg_mobject.py:97) when neither the svg_string parameter, nor the file_name parameter, nor the class-level self.file_name attribute is non-empty. The constructor needs exactly one SVG source; with all three empty there is nothing to parse.","triggerScenarios":"Calling SVGMobject() directly; subclassing SVGMobject but forgetting to set the class attribute file_name = 'my_icon.svg'; passing file_name='' explicitly.","commonSituations":"Creating a reusable SVGMobject subclass where the author intended to set file_name as a class field but omitted it; passing a file_name that is falsy after a bug in path-building code.","solutions":["Pass the SVG explicitly: SVGMobject('my_icon.svg') or SVGMobject(svg_string='<svg ...>...')","In subclasses, set the class attribute: class MyIcon(SVGMobject): file_name = 'my_icon.svg'","Check inputs before construction: assert svg_string or file_name"],"exampleFix":"# before\nclass Logo(SVGMobject):\n    pass  # forgot file_name\nLogo()  # raises\n\n# after\nclass Logo(SVGMobject):\n    file_name = 'logo.svg'\nLogo()","handlingStrategy":"validation","validationCode":"assert svg_string or file_name or getattr(cls, 'file_name', ''), \\\n    'SVGMobject needs svg_string, file_name arg, or class-level file_name'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass file_name or svg_string to SVGMobject","In subclasses, set the class attribute file_name = 'name.svg'","Check inputs in factory functions before constructing SVGMobject"],"tags":["manim","svg","constructor","required-argument"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}