langgenius/dify · error · CompletionRequestError

completion_request_error

completion_request_error

Error message

Completion request failed.

What it means

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.

Source

Thrown at api/controllers/console/app/message.py:529

        questions = MessageService.get_suggested_questions_after_answer(
            app_model=app_model,
            message_id=message_id_str,
            user=current_user,
            invoke_from=InvokeFrom.DEBUGGER,
            session=session,
        )
    except MessageNotExistsError:
        raise NotFound("Message not found")
    except ConversationNotExistsError:
        raise NotFound("Conversation not found")
    except ProviderTokenNotInitError as ex:
        raise ProviderNotInitializeError(ex.description)
    except QuotaExceededError:
        raise ProviderQuotaExceededError()
    except ModelCurrentlyNotSupportError:
        raise ProviderModelCurrentlyNotSupportError()
    except InvokeError as e:
        raise CompletionRequestError(e.description)
    except SuggestedQuestionsAfterAnswerDisabledError:
        raise AppSuggestedQuestionsAfterAnswerDisabledError()
    except Exception:
        logger.exception("internal server error.")
        raise InternalServerError()

    return dump_response(SuggestedQuestionsResponse, {"data": questions})


def _get_message_detail(*, session: Session, app_model: App, message_id: UUID):
    message_id_str = str(message_id)

    message = session.scalar(
        select(Message).where(Message.id == message_id_str, Message.app_id == app_model.id).limit(1)
    )

    if not message:
        raise NotFound("Message Not Exists.")

View on GitHub (pinned to ef8544b173)

Solutions

  1. Verify the model provider credentials are valid in Settings > Model Provider and that the chosen model is still listed as available.
  2. Retry the request once after a short delay to rule out transient upstream failures.
  3. Check provider dashboard/quotas for rate-limit or spending cap exhaustion.
  4. Inspect server logs (logger captured the InvokeError description) for the provider-specific message to pinpoint auth vs. model-vs-network.
  5. Switch the app to a different, known-good model and retry to isolate provider-specific issues.
Defensive patterns

Strategy: retry

Validate before calling

// Validate provider health before calling suggested-questions
// (no client-side guard fully prevents transient invoke failures)
// Pre-check: ensure the app model is configured and reachable
async function modelReady(appId) {
  const cfg = await fetch(`/console/apps/${appId}/model-config`).then(r=>r.json())
  return !!cfg?.provider && !!cfg?.model
}

Try / catch

// Retry once on completion_request_error, then surface to the user
try {
  return await fetch(`/apps/${appId}/messages/${msgId}/suggested-questions`)
} catch (e) {
  if (e.code === 'completion_request_error' && !retried) { retried = true; return retry() }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12). Data as JSON: /api/errors/dc8b3fc8caf42f06. Report an issue: GitHub.