langgenius/dify · error · NotFound

Conversation not found

Error message

Conversation not found

What it means

HTTP 404 NotFound with body message 'Conversation not found', raised when MessageService.get_suggested_questions_after_answer raises ConversationNotExistsError. The message itself may resolve, but its parent conversation does not (deleted, wrong app, or tenant mismatch). Distinct from the message-level 404: this indicates the conversational container is gone.

Source

Thrown at api/controllers/console/explore/trial.py:641

        app_model = trial_app
        app_mode = AppMode.value_of(app_model.mode)
        if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:
            raise NotChatAppError()

        message_id = str(message_id)

        try:
            questions = MessageService.get_suggested_questions_after_answer(
                app_model=app_model,
                user=current_user,
                message_id=message_id,
                invoke_from=InvokeFrom.EXPLORE,
                session=db.session(),
            )
        except MessageNotExistsError:
            raise NotFound("Message not found")
        except ConversationNotExistsError:
            raise NotFound("Conversation not found")
        except SuggestedQuestionsAfterAnswerDisabledError:
            raise AppSuggestedQuestionsAfterAnswerDisabledError()
        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 Exception:
            logger.exception("internal server error.")
            raise InternalServerError()

        return {"data": questions}


class TrialChatAudioApi(TrialAppResource):

View on GitHub (pinned to ef8544b173)

Solutions

  1. Treat 404 with 'Conversation not found' as a signal to start a new conversation - discard the cached conversation/message ids.
  2. If unexpected, check whether a retention job or admin deleted the conversation and whether the message's conversation_id matches the app.
  3. Re-fetch the conversation list for the app to confirm what still exists.

Example fix

// before
const r = await fetch(suggestedUrl)
if (!r.ok) throw new Error('failed')

// after - distinguish conversation-vs-message 404
const r = await fetch(suggestedUrl)
if (r.status === 404) {
  const body = await r.json()
  if (body.message === 'Conversation not found') startNewConversation()
  else discardMessage()
  return
}
Defensive patterns

Strategy: validation

Validate before calling

const convs = await fetch(`/console/api/explore/apps/${appId}/conversations`).then(r => r.json())
const exists = (convs.data || []).some(c => c.id === conversationId)
if (!exists) throw new Error('conversation not found')

Try / catch

try {
  const r = await fetch(suggestedUrl)
  if (r.status === 404) {
    const body = await r.json()
    if (body.message === 'Conversation not found') startNewConversation()
  }
} catch (e) { reportToUser(e) }

Prevention

When it happens

Trigger: GET suggested-questions where the message's conversation_id no longer exists in the DB for this app. Common when the conversation was deleted but the message row lingered, or when the conversation belongs to a different app than the trial app in the URL.

Common situations: Conversation deleted by the user or a cleanup task while a client still holds a message link; cross-app id confusion in a multi-tenant deploy; partial DB restore that left orphan messages.

Related errors


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