{"record":{"id":"0af0b5a8e975ec75","repo":"micro/go-micro","slug":"no-response-from-api","errorCode":null,"errorMessage":"no response from API","messagePattern":"no response from API","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ai/atlascloud/atlascloud.go","lineNumber":470,"sourceCode":"\t\t}\n\t\treturn nil, nil, &atlascloudAPIError{Status: httpResp.Status, Code: httpResp.StatusCode, Retry: retryAfter, Phase: phase, Summary: atlascloudRequestSummary(req), Body: string(respBody)}\n\t}\n\n\tvar chatResp struct {\n\t\tChoices []struct {\n\t\t\tMessage struct {\n\t\t\t\tContent   string          `json:\"content\"`\n\t\t\t\tToolCalls []atlasToolCall `json:\"tool_calls\"`\n\t\t\t} `json:\"message\"`\n\t\t} `json:\"choices\"`\n\t}\n\n\tif err := json.Unmarshal(respBody, &chatResp); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to parse response: %w\", err)\n\t}\n\n\tif len(chatResp.Choices) == 0 {\n\t\treturn nil, nil, fmt.Errorf(\"no response from API\")\n\t}\n\n\tchoice := chatResp.Choices[0]\n\tresponse := &ai.Response{\n\t\tReply: choice.Message.Content,\n\t}\n\n\tfor _, tc := range choice.Message.ToolCalls {\n\t\tvar input map[string]any\n\t\tif err := json.Unmarshal([]byte(tc.Function.Arguments), &input); err != nil {\n\t\t\tinput = map[string]any{}\n\t\t}\n\t\tresponse.ToolCalls = append(response.ToolCalls, ai.ToolCall{\n\t\t\tID:    tc.ID,\n\t\t\tName:  tc.Function.Name,\n\t\t\tInput: input,\n\t\t})\n\t}","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/micro/go-micro/blob/24529f140421a11a33b6999ab7944f2021cfd69c/ai/atlascloud/atlascloud.go#L452-L488","documentation":"After a successful JSON decode, callAPI checks that chatResp.Choices is non-empty; if the API returned a valid chat-completion envelope with zero choices, this plain error is thrown. It means the request technically succeeded but the model produced no selectable completion.","triggerScenarios":"json.Unmarshal succeeds but len(chatResp.Choices) == 0 — the API replied 200 with choices: [] (or omitted), e.g. the request was entirely filtered or the model returned nothing.","commonSituations":"Prompt fully consumed by moderation/safety filtering, an invalid model name that the API accepts but yields no output, empty prompt/messages payload, or provider-side degraded responses during outages.","solutions":["Inspect the raw response body for a filter/finish_reason indication (log the full body before this check).","Verify the requested model name and that the messages/prompt payload is non-empty and well-formed.","Retry the request; if reproducible, rephrase the prompt to avoid content that may be filtered.","Treat it as retryable transient behavior and add backoff retry at the Generate call site."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"resp, err := provider.Generate(ctx, req)\nif err != nil {\n    if strings.Contains(err.Error(), \"no response from API\") {\n        // retry once or fall back to another provider/model\n        resp, err = provider.Generate(ctx, req)\n    }\n    if err != nil {\n        return err\n    }\n}","preventionTips":["Always send a non-empty messages/prompt payload.","Use model names verified against the current AtlasCloud model list.","Inspect finish_reason / raw body when empty responses occur to detect moderation filtering.","Add a retry with backoff for empty responses, which are often transient."],"tags":["empty-response","api","go","atlascloud"],"backgroundTag":"empty-api-response","analyzedSha":"24529f140421a11a33b6999ab7944f2021cfd69c","analyzedAt":"2026-09-01T02:52:24.923Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}