{"record":{"id":"ab62a223cbde8696","repo":"micro/go-micro","slug":"image-generation-failed-s","errorCode":null,"errorMessage":"image generation failed: %s","messagePattern":"image generation failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ai/atlascloud/atlascloud.go","lineNumber":1038,"sourceCode":"\t\tData struct {\n\t\t\tStatus  string   `json:\"status\"`\n\t\t\tOutputs []string `json:\"outputs\"`\n\t\t\tError   string   `json:\"error\"`\n\t\t} `json:\"data\"`\n\t}\n\tif err := json.Unmarshal(body, &pollResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse poll response: %w\", err)\n\t}\n\n\tswitch pollResp.Data.Status {\n\tcase \"completed\":\n\t\tresp := &ai.ImageResponse{}\n\t\tfor _, output := range pollResp.Data.Outputs {\n\t\t\tresp.Images = append(resp.Images, ai.Image{URL: output})\n\t\t}\n\t\treturn resp, nil\n\tcase \"failed\":\n\t\treturn nil, fmt.Errorf(\"image generation failed: %s\", pollResp.Data.Error)\n\tdefault:\n\t\treturn nil, nil\n\t}\n}\n\nconst defaultVideoModel = \"google/gemini-omni-flash/image-to-video-developer\"\n\n// GenerateVideo creates a video using Atlas Cloud's async video API.\n// Supports text-to-video and image-to-video depending on whether\n// Images are provided in the request.\nfunc (p *Provider) GenerateVideo(ctx context.Context, req *ai.VideoRequest, opts ...ai.GenerateOption) (*ai.VideoResponse, error) {\n\tmodel := req.Model\n\tif model == \"\" {\n\t\tmodel = defaultVideoModel\n\t}\n\tduration := req.Duration\n\tif duration <= 0 {\n\t\tduration = 6","sourceCodeStart":1020,"sourceCodeEnd":1056,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/ai/atlascloud/atlascloud.go#L1020-L1056","documentation":"Thrown by pollPrediction when the Atlas Cloud poll endpoint reports the image job's status as \"failed\". The provider surfaces the job-level Error string from the API response. This means the submission succeeded but the generation itself failed server-side.","triggerScenarios":"GenerateImage submits a job, polling continues until status==\"failed\"; pollResp.Data.Error from the API is embedded into the message. Typically caused by an invalid/unsupported model name, a rejected prompt (content policy), or invalid image inputs.","commonSituations":"Using a model slug that no longer exists on Atlas Cloud; prompts violating the provider's content policy; requesting unsupported dimensions/parameters; provider-side capacity failures; expired model deprecations after an API update.","solutions":["Read the embedded pollResp.Data.Error message in the error text — it states the server-side reason","Verify the model slug passed in req.Model exists and is enabled for your Atlas Cloud account","Adjust the prompt if the error indicates a content-policy violation","Retry with a different model or simplified parameters to rule out transient capacity issues","Check your Atlas Cloud account quota/credits if the error references billing"],"exampleFix":"// before\ncase \"failed\":\n\treturn nil, fmt.Errorf(\"image generation failed: %s\", pollResp.Data.Error)\n// after: make the model/job identifiable for debugging\ncase \"failed\":\n\treturn nil, fmt.Errorf(\"image generation failed (job %s, model %s): %s\", jobID, model, pollResp.Data.Error)","handlingStrategy":"try-catch","validationCode":"// pre-validate inputs the provider commonly rejects\nif prompt == \"\" || len(prompt) > 4000 {\n\treturn fmt.Errorf(\"prompt empty or too long\")\n}\nif model != \"\" && !supportedModels[model] {\n\treturn fmt.Errorf(\"unsupported model %q\", model)\n}","typeGuard":"func isGenerationFailedErr(err error) (string, bool) {\n\tmsg := err.Error()\n\tif strings.HasPrefix(msg, \"image generation failed:\") {\n\t\treturn strings.TrimPrefix(msg, \"image generation failed: \"), true\n\t}\n\treturn \"\", false\n}","tryCatchPattern":"resp, err := provider.GenerateImage(ctx, req)\nif err != nil {\n\tif reason, ok := isGenerationFailedErr(err); ok {\n\t\tlog.Printf(\"provider rejected generation: %s — adjusting prompt/model\", reason)\n\t\treturn fallbackModel(ctx, req)\n\t}\n\treturn err\n}","preventionTips":["Keep model slugs in a validated allowlist refreshed from provider docs","Screen prompts against known content-policy rules before submitting","Fallback to an alternate model on provider-side failure","Monitor the provider status/changelog for model deprecations"],"tags":["image-generation","api-error","polling","provider-error"],"backgroundTag":"generation-job-failed","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}