{"record":{"id":"0bde3572da28a9a0","repo":"micro/go-micro","slug":"api-error-s","errorCode":null,"errorMessage":"API error: %s","messagePattern":"API error: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ai/atlascloud/atlascloud.go","lineNumber":979,"sourceCode":"\n\trespBody, _ := io.ReadAll(httpResp.Body)\n\tif httpResp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"API error (%s): %s\", httpResp.Status, string(respBody))\n\t}\n\n\tvar submitResp struct {\n\t\tCode int    `json:\"code\"`\n\t\tMsg  string `json:\"message\"`\n\t\tData struct {\n\t\t\tID     string `json:\"id\"`\n\t\t\tStatus string `json:\"status\"`\n\t\t} `json:\"data\"`\n\t}\n\tif err := json.Unmarshal(respBody, &submitResp); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to parse submit response: %w\", err)\n\t}\n\tif submitResp.Code != 200 {\n\t\treturn nil, fmt.Errorf(\"API error: %s\", submitResp.Msg)\n\t}\n\n\tpredictionID := submitResp.Data.ID\n\tpollURL := strings.TrimRight(p.opts.BaseURL, \"/\") + \"/api/v1/model/prediction/\" + predictionID\n\n\tticker := time.NewTicker(2 * time.Second)\n\tdefer ticker.Stop()\n\n\tfor {\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn nil, ctx.Err()\n\t\tcase <-ticker.C:\n\t\t\tresult, err := p.pollPrediction(ctx, pollURL)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif result != nil {","sourceCodeStart":961,"sourceCodeEnd":997,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/ai/atlascloud/atlascloud.go#L961-L997","documentation":"After decoding the submit response, GenerateImage checks the application-level code field; anything other than 200 throws this error carrying the API's message string. It means the HTTP call succeeded but AtlasCloud rejected the generation request at the business-logic level, before polling begins.","triggerScenarios":"submitResp.Code != 200 on a 200 HTTP response — e.g. code 401/1001 for invalid key, 429 for quota, or validation codes for unsupported parameters in the image request.","commonSituations":"Valid HTTP but invalid API key at the application layer, insufficient credits/quota for image generation, model name or parameter values rejected by AtlasCloud's validation, or deprecated model referenced.","solutions":["Read the Msg in the error — it states the business-level reason from AtlasCloud.","For auth codes, re-check/rotate the API key used by the provider options.","For quota codes, check billing/limits on the AtlasCloud dashboard and back off.","Validate model name and image parameters (dimensions, prompt length) against current AtlasCloud docs."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if model == \"\" || !slices.Contains(supportedAtlasImageModels, model) {\n    return fmt.Errorf(\"unsupported AtlasCloud image model: %q\", model)\n}","typeGuard":null,"tryCatchPattern":"img, err := provider.GenerateImage(ctx, req)\nif err != nil {\n    if strings.Contains(err.Error(), \"API error:\") {\n        // business-level rejection: read the message, adjust key/quota/params\n        return fmt.Errorf(\"atlascloud rejected generation: %w\", err)\n    }\n    return err\n}","preventionTips":["Read the Msg embedded in the error — AtlasCloud states the exact business reason.","Validate model names and image parameters against current docs before calling.","Monitor credits/quota and alert before exhaustion.","Distinguish these app-level errors from HTTP transport errors when designing retries."],"tags":["api-error","business-logic","go","atlascloud"],"backgroundTag":"api-application-error","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}