{"record":{"id":"cedc28148383703d","repo":"lllyasviel/Fooocus","slug":"invalid-value-for-parameter-source-source-pl","errorCode":null,"errorMessage":"Invalid value for parameter `source`: {source}. Please choose from one of: {valid_sources}","messagePattern":"Invalid value for parameter `source`: (.+?)\\. Please choose from one of: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"modules/gradio_hijack.py","lineNumber":137,"sourceCode":"            show_share_button: If True, will show a share icon in the corner of the component that allows user to share outputs to Hugging Face Spaces Discussions. If False, icon does not appear. If set to None (default behavior), then the icon appears if this Gradio app is launched on Spaces, but not otherwise.\n        \"\"\"\n        self.brush_radius = brush_radius\n        self.brush_color = brush_color\n        self.mask_opacity = mask_opacity\n        self.mirror_webcam = mirror_webcam\n        valid_types = [\"numpy\", \"pil\", \"filepath\"]\n        if type not in valid_types:\n            raise ValueError(\n                f\"Invalid value for parameter `type`: {type}. Please choose from one of: {valid_types}\"\n            )\n        self.type = type\n        self.shape = shape\n        self.height = height\n        self.width = width\n        self.image_mode = image_mode\n        valid_sources = [\"upload\", \"webcam\", \"canvas\"]\n        if source not in valid_sources:\n            raise ValueError(\n                f\"Invalid value for parameter `source`: {source}. Please choose from one of: {valid_sources}\"\n            )\n        self.source = source\n        if tool is None:\n            self.tool = \"sketch\" if source == \"canvas\" else \"editor\"\n        else:\n            self.tool = tool\n        self.invert_colors = invert_colors\n        self.streaming = streaming\n        self.show_download_button = show_download_button\n        if streaming and source != \"webcam\":\n            raise ValueError(\"Image streaming only available if source is 'webcam'.\")\n        self.select: EventListenerMethod\n        \"\"\"\n        Event listener for when the user clicks on a pixel within the image.\n        Uses event data gradio.SelectData to carry `index` to refer to the [x, y] coordinates of the clicked pixel.\n        See EventData documentation on how to use this event data.\n        \"\"\"","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/modules/gradio_hijack.py#L119-L155","documentation":"The same vendored gradio Image constructor validates source (where the image comes from) against ['upload', 'webcam', 'canvas']; anything else raises ValueError. Note this vendored version still supports source=, whereas gradio removed the parameter in 4.x — mixing APIs between versions is the usual cause.","triggerScenarios":"Constructing Image(source='file'), source='camera', source='sketch', or source=None with the hijacked component; passing tool/source combinations from newer gradio examples.","commonSituations":"See trigger scenarios.","solutions":["Use exactly 'upload', 'webcam', or 'canvas' for source.","For sketch input use source='canvas' (tool defaults to 'sketch'); for plain upload use 'upload'.","Do not feed gradio 3/4 example code into this vendored component — check modules/gradio_hijack.py's own signatures."],"exampleFix":"# before\nImage(source='sketch', tool='sketch')\n# after\nImage(source='canvas', tool='sketch')","handlingStrategy":"validation","validationCode":"SOURCES = ('upload', 'webcam', 'canvas')\nassert source in SOURCES, f'source must be one of {SOURCES}'","typeGuard":"def is_gradio_image_source(v) -> bool:\n    return v in ('upload', 'webcam', 'canvas')","tryCatchPattern":null,"preventionTips":["Map intent to the vendored vocabulary: file picker→'upload', camera→'webcam', draw→'canvas'.","Never copy source= values from gradio 4.x examples (parameter removed upstream)."],"tags":["gradio","ui","constructor-validation","version-compatibility"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}