{"record":{"id":"90d245079976fa74","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"unknown-prompt-type-prompt-type","errorCode":null,"errorMessage":"Unknown prompt type {prompt_type}","messagePattern":"Unknown prompt type (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scripts/prompt_matrix.py","lineNumber":62,"sourceCode":"    def ui(self, is_img2img):\r\n        gr.HTML('<br />')\r\n        with gr.Row():\r\n            with gr.Column():\r\n                put_at_start = gr.Checkbox(label='Put variable parts at start of prompt', value=False, elem_id=self.elem_id(\"put_at_start\"))\r\n                different_seeds = gr.Checkbox(label='Use different seed for each picture', value=False, elem_id=self.elem_id(\"different_seeds\"))\r\n            with gr.Column():\r\n                prompt_type = gr.Radio([\"positive\", \"negative\"], label=\"Select prompt\", elem_id=self.elem_id(\"prompt_type\"), value=\"positive\")\r\n                variations_delimiter = gr.Radio([\"comma\", \"space\"], label=\"Select joining char\", elem_id=self.elem_id(\"variations_delimiter\"), value=\"comma\")\r\n            with gr.Column():\r\n                margin_size = gr.Slider(label=\"Grid margins (px)\", minimum=0, maximum=500, value=0, step=2, elem_id=self.elem_id(\"margin_size\"))\r\n\r\n        return [put_at_start, different_seeds, prompt_type, variations_delimiter, margin_size]\r\n\r\n    def run(self, p, put_at_start, different_seeds, prompt_type, variations_delimiter, margin_size):\r\n        modules.processing.fix_seed(p)\r\n        # Raise error if promp type is not positive or negative\r\n        if prompt_type not in [\"positive\", \"negative\"]:\r\n            raise ValueError(f\"Unknown prompt type {prompt_type}\")\r\n        # Raise error if variations delimiter is not comma or space\r\n        if variations_delimiter not in [\"comma\", \"space\"]:\r\n            raise ValueError(f\"Unknown variations delimiter {variations_delimiter}\")\r\n\r\n        prompt = p.prompt if prompt_type == \"positive\" else p.negative_prompt\r\n        original_prompt = prompt[0] if type(prompt) == list else prompt\r\n        positive_prompt = p.prompt[0] if type(p.prompt) == list else p.prompt\r\n\r\n        delimiter = \", \" if variations_delimiter == \"comma\" else \" \"\r\n\r\n        all_prompts = []\r\n        prompt_matrix_parts = original_prompt.split(\"|\")\r\n        combination_count = 2 ** (len(prompt_matrix_parts) - 1)\r\n        for combination_num in range(combination_count):\r\n            selected_prompts = [text.strip().strip(',') for n, text in enumerate(prompt_matrix_parts[1:]) if combination_num & (1 << n)]\r\n\r\n            if put_at_start:\r\n                selected_prompts = selected_prompts + [prompt_matrix_parts[0]]\r","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/scripts/prompt_matrix.py#L44-L80","documentation":"The built-in Prompt Matrix script validates its gradio inputs at run() time: prompt_type must be exactly 'positive' or 'negative' (matching the Radio choices defined in ui()). API callers or saved payloads that send anything else are rejected with this ValueError before prompt construction.","triggerScenarios":"Calling /sdapi/v1/txt2img with alwayson_scripts.prompt_matrix.args = [put_at_start, different_seeds, prompt_type, delimiter, margin] where prompt_type is e.g. 'Positive', None, or a language-changed value; gradio normally constrains the UI, so this is almost always an API/script caller.","commonSituations":"Programmatic API clients passing positional script args in the wrong order (prompt_type receiving the delimiter value); localized or hand-built payloads; typo'd enum strings.","solutions":["Set prompt_type to exactly 'positive' or 'negative'","Re-check the argument order of the prompt_matrix script args: [put_at_start, different_seeds, prompt_type, variations_delimiter, margin_size]","When building API payloads programmatically, validate the value against the allowed list before sending"],"exampleFix":"# before\nargs = [False, False, 'pos', 'comma', 0]\n# after\nargs = [False, False, 'positive', 'comma', 0]","handlingStrategy":"type-guard","validationCode":"ALLOWED_PROMPT_TYPES = {'positive', 'negative'}\ndef args_valid(args) -> bool:\n    return len(args) == 5 and args[2] in ALLOWED_PROMPT_TYPES","typeGuard":"def is_prompt_type(v) -> bool:\n    return v in ('positive', 'negative')","tryCatchPattern":null,"preventionTips":["Send script args by named structure or verify the documented positional order","Whitelist enum values client-side before calling the API","Log the exact args array when a script validation fires"],"tags":["script","prompt-matrix","api","validation","user-input"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}