{"record":{"id":"d4b11384a571a001","repo":"siyuan-note/siyuan","slug":"minimax-image-size-must-be-widthxheight","errorCode":null,"errorMessage":"MiniMax image size must be WIDTHxHEIGHT","messagePattern":"MiniMax image size must be WIDTHxHEIGHT","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/minimax_image.go","lineNumber":70,"sourceCode":"\t\tPrompt string `json:\"prompt\"`\n\t\tSize   string `json:\"size\"`\n\t\tN      int    `json:\"n\"`\n\t}\n\terr := json.NewDecoder(req.Body).Decode(&input)\n\treq.Body.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpayload := map[string]any{\n\t\t\"model\": input.Model, \"prompt\": input.Prompt, \"n\": input.N,\n\t\t\"response_format\": \"url\", \"prompt_optimizer\": true,\n\t}\n\tif input.Size == \"\" || input.Size == \"auto\" {\n\t\tpayload[\"aspect_ratio\"] = \"1:1\"\n\t} else {\n\t\tdimensions := strings.Split(input.Size, \"x\")\n\t\tif len(dimensions) != 2 {\n\t\t\treturn nil, errors.New(\"MiniMax image size must be WIDTHxHEIGHT\")\n\t\t}\n\t\twidth, widthErr := strconv.Atoi(dimensions[0])\n\t\theight, heightErr := strconv.Atoi(dimensions[1])\n\t\tif widthErr != nil || heightErr != nil || width <= 0 || height <= 0 {\n\t\t\treturn nil, errors.New(\"MiniMax image dimensions must be positive integers\")\n\t\t}\n\t\tpayload[\"width\"], payload[\"height\"] = width, height\n\t}\n\tbody, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconverted := req.Clone(req.Context())\n\tconverted.URL.Path = strings.TrimSuffix(req.URL.Path, \"/images/generations\") + \"/image_generation\"\n\tconverted.URL.RawPath = \"\"\n\tconverted.Body = io.NopCloser(bytes.NewReader(body))\n\tconverted.ContentLength = int64(len(body))\n\tconverted.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(body)), nil }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/minimax_image.go#L52-L88","documentation":"The MiniMax image transport rewrites OpenAI-style /images/generations requests into MiniMax's /image_generation API. MiniMax takes explicit width/height rather than the OpenAI \"SIZE\" string, so the transport parses input.Size by splitting on \"x\" and requires exactly two parts. Anything else (one part, three parts, empty separators) is rejected with this error.","triggerScenarios":"Requesting an image generation against a MiniMax endpoint (api.minimax.io/.cn/api.minimaxi.com) with size set to a non \"WxH\" string, e.g. \"1024\" (no x), \"1024X1024\" (capital X), \"1x1x1\", or an OpenAI-style keyword other than \"auto\" like \"large\".","commonSituations":"Reusing OpenAI DALL-E size keywords or configs copied from an OpenAI provider where sizes like \"1024x1024, 1792x1024\" are valid; case-sensitive \"X\" separator typo; plugin passing a free-form size label.","solutions":["Set input.Size to strict \"WIDTHxHEIGHT\" format with lowercase x, e.g. \"1024x1024\"","Use \"\" or \"auto\" to get the default 1:1 aspect ratio instead of a keyword size","Normalize the size string before the request: lowercase it and validate the WxH pattern","If the value comes from user config, validate it at config-save time with a regex like ^\\d+x\\d+$"],"exampleFix":"// before\nsize := \"1024X1024\" // capital X -> split gives 1 part\n// after\nsize := strings.ToLower(strings.TrimSpace(size))\nif matched, _ := regexp.MatchString(`^\\d+x\\d+$`, size); !matched && size != \"\" && size != \"auto\" {\n    size = \"\" // fall back to default aspect ratio\n}","handlingStrategy":"validation","validationCode":"valid, _ := regexp.MatchString(`^\\d+x\\d+$`, size)\nif !valid && size != \"\" && size != \"auto\" { size = \"\" } // default 1:1","typeGuard":null,"tryCatchPattern":"resp, err := client.CreateImages(ctx, req)\nif err != nil {\n    if strings.Contains(err.Error(), \"must be WIDTHxHEIGHT\") {\n        req.Size = \"\" // fall back to default aspect ratio and retry once\n        resp, err = client.CreateImages(ctx, req)\n    }\n    if err != nil { return err }\n}","preventionTips":["Store provider-agnostic size as WxH lowercase-x only, validated at config save","Map OpenAI size keywords to explicit WxH values when targeting MiniMax","Never pass user-supplied size strings straight through without a regex check","Prefer omitting Size (default 1:1) unless exact dimensions are required"],"tags":["go","minimax","image-generation","parameter-format"],"backgroundTag":"invalid-argument-format","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}