{"record":{"id":"d1c57192d3448472","repo":"siyuan-note/siyuan","slug":"minimax-image-model-returned-no-image","errorCode":null,"errorMessage":"MiniMax image model returned no image","messagePattern":"MiniMax image model returned no image","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/util/minimax_image.go","lineNumber":114,"sourceCode":"\t}\n\tvar output struct {\n\t\tData struct {\n\t\t\tURLs []string `json:\"image_urls\"`\n\t\t} `json:\"data\"`\n\t\tBaseResp *struct {\n\t\t\tStatusCode int `json:\"status_code\"`\n\t\t} `json:\"base_resp\"`\n\t}\n\terr = json.NewDecoder(io.LimitReader(resp.Body, 1024*1024)).Decode(&output)\n\tresp.Body.Close()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif output.BaseResp == nil || output.BaseResp.StatusCode != 0 {\n\t\treturn nil, errors.New(\"MiniMax image generation failed\")\n\t}\n\tif len(output.Data.URLs) == 0 || output.Data.URLs[0] == \"\" {\n\t\treturn nil, errors.New(\"MiniMax image model returned no image\")\n\t}\n\tdata := make([]map[string]string, 0, len(output.Data.URLs))\n\tfor _, imageURL := range output.Data.URLs {\n\t\tdata = append(data, map[string]string{\"url\": imageURL})\n\t}\n\tbody, err = json.Marshal(map[string]any{\"data\": data})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresp.Body = io.NopCloser(bytes.NewReader(body))\n\tresp.ContentLength = int64(len(body))\n\tresp.Header.Set(\"Content-Length\", strconv.Itoa(len(body)))\n\treturn resp, nil\n}\n","sourceCodeStart":96,"sourceCodeEnd":129,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/util/minimax_image.go#L96-L129","documentation":"After MiniMax reports success (base_resp.status_code == 0), the transport checks that data.image_urls contains at least one non-empty URL. If the array is empty or the first URL is an empty string, it throws this error: the API said the generation succeeded but produced no usable image reference.","triggerScenarios":"A 2xx MiniMax /image_generation response with status_code 0 but an empty or missing data.image_urls array — typically when the requested n is 0 or unset in the converted payload, or MiniMax returns a degenerate success response.","commonSituations":"Calling image generation with n explicitly set to 0, an unusual aspect/size combination MiniMax silently fails to render, or transient MiniMax-side issues where success is reported without output.","solutions":["Ensure the request sets n >= 1 (the OpenAI-style request's n field is forwarded verbatim)","Retry the generation — transient degenerate successes usually resolve","Change or simplify the prompt and size/aspect_ratio parameters and try again","Check MiniMax service status or announcements for incidents affecting image generation","If persistent, capture the raw response and report it to MiniMax support"],"exampleFix":"// before\n{\"model\":\"image-01\",\"prompt\":\"a cat\",\"n\":0}\n// after\n{\"model\":\"image-01\",\"prompt\":\"a cat\",\"n\":1}","handlingStrategy":"retry","validationCode":"if n <= 0 {\n    n = 1 // MiniMax returns empty image_urls when n is 0\n}","typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 3; attempt++ {\n    data, err = generateImage(req)\n    if err == nil || err.Error() != \"MiniMax image model returned no image\" {\n        break\n    }\n    time.Sleep(backoff(attempt))\n}","preventionTips":["Always request n >= 1","Retry once or twice on degenerate empty successes","Vary size/aspect_ratio if empty results persist","Watch MiniMax status pages for generation incidents"],"tags":["minimax","image-generation","empty-result"],"backgroundTag":"empty-result-set","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"}