{"record":{"id":"dc8b3fc8caf42f06","repo":"langgenius/dify","slug":"completion-request-error-dc8b3f","errorCode":"completion_request_error","errorMessage":"Completion request failed.","messagePattern":"Completion request failed\\.","errorType":"error_code","errorClass":"CompletionRequestError","httpStatus":400,"severity":"error","filePath":"api/controllers/console/app/message.py","lineNumber":529,"sourceCode":"        questions = MessageService.get_suggested_questions_after_answer(\n            app_model=app_model,\n            message_id=message_id_str,\n            user=current_user,\n            invoke_from=InvokeFrom.DEBUGGER,\n            session=session,\n        )\n    except MessageNotExistsError:\n        raise NotFound(\"Message not found\")\n    except ConversationNotExistsError:\n        raise NotFound(\"Conversation not found\")\n    except ProviderTokenNotInitError as ex:\n        raise ProviderNotInitializeError(ex.description)\n    except QuotaExceededError:\n        raise ProviderQuotaExceededError()\n    except ModelCurrentlyNotSupportError:\n        raise ProviderModelCurrentlyNotSupportError()\n    except InvokeError as e:\n        raise CompletionRequestError(e.description)\n    except SuggestedQuestionsAfterAnswerDisabledError:\n        raise AppSuggestedQuestionsAfterAnswerDisabledError()\n    except Exception:\n        logger.exception(\"internal server error.\")\n        raise InternalServerError()\n\n    return dump_response(SuggestedQuestionsResponse, {\"data\": questions})\n\n\ndef _get_message_detail(*, session: Session, app_model: App, message_id: UUID):\n    message_id_str = str(message_id)\n\n    message = session.scalar(\n        select(Message).where(Message.id == message_id_str, Message.app_id == app_model.id).limit(1)\n    )\n\n    if not message:\n        raise NotFound(\"Message Not Exists.\")","sourceCodeStart":511,"sourceCodeEnd":547,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/controllers/console/app/message.py#L511-L547","documentation":"Raised as CompletionRequestError when the underlying LLM provider InvokeError occurs during suggested-questions generation (api/controllers/console/app/message.py:528-529). It signals that the model invocation to generate follow-up question suggestions failed at the provider layer — network, auth, rate-limit, or model-side failure. The controller translates services.errors.llm.InvokeError into this HTTP-layer error so the client sees a single completion_request_error code rather than provider-specific exceptions.","triggerScenarios":"Calling GET /console/apps/{app_id}/messages/{message_id}/suggested-questions when the configured model provider fails to invoke (bad API key, model unavailable, upstream 5xx, or quota mid-request). The invoke happens inside MessageService.get_suggested_questions_after_answer.","commonSituations":"Provider API key expired or rotated; model name removed/renamed by the vendor; intermittent upstream outage; per-minute rate limit hit on the provider; misconfigured model credential that still passes init but fails at invoke time.","solutions":["Verify the model provider credentials are valid in Settings > Model Provider and that the chosen model is still listed as available.","Retry the request once after a short delay to rule out transient upstream failures.","Check provider dashboard/quotas for rate-limit or spending cap exhaustion.","Inspect server logs (logger captured the InvokeError description) for the provider-specific message to pinpoint auth vs. model-vs-network.","Switch the app to a different, known-good model and retry to isolate provider-specific issues."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Validate provider health before calling suggested-questions\n// (no client-side guard fully prevents transient invoke failures)\n// Pre-check: ensure the app model is configured and reachable\nasync function modelReady(appId) {\n  const cfg = await fetch(`/console/apps/${appId}/model-config`).then(r=>r.json())\n  return !!cfg?.provider && !!cfg?.model\n}","typeGuard":null,"tryCatchPattern":"// Retry once on completion_request_error, then surface to the user\ntry {\n  return await fetch(`/apps/${appId}/messages/${msgId}/suggested-questions`)\n} catch (e) {\n  if (e.code === 'completion_request_error' && !retried) { retried = true; return retry() }\n  throw e\n}","preventionTips":["Keep model provider credentials valid and monitored.","Pin stable model names; alert when a model is deprecated.","Implement client-side retry with backoff for transient provider errors."],"tags":["llm-provider","suggested-questions","invoke-error","api"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}