langgenius/dify · error · NotFound

Conversation Not Exists.

Error message

Conversation Not Exists.

What it means

HTTP 404 raised by GET /installed-apps/<id>/messages when MessageService.pagination_by_first_id raises ConversationNotExistsError. The conversation_id query parameter does not resolve to a conversation for this app/user.

Source

Thrown at api/controllers/console/explore/message.py:109

                app_model,
                current_user,
                args.conversation_id,
                args.first_id or None,
                args.limit,
                session=session,
            )
            adapter = TypeAdapter(ExploreMessageListItem)
            items = [
                adapter.validate_python(MessageResponseSource(message, session=session), from_attributes=True)
                for message in pagination.data
            ]
            return ExploreMessageInfiniteScrollPagination(
                limit=pagination.limit,
                has_more=pagination.has_more,
                data=items,
            ).model_dump(mode="json")
        except ConversationNotExistsError:
            raise NotFound("Conversation Not Exists.")
        except FirstMessageNotExistsError:
            raise NotFound("First Message Not Exists.")


@console_ns.route(
    "/installed-apps/<uuid:installed_app_id>/messages/<uuid:message_id>/feedbacks",
    endpoint="installed_app_message_feedback",
)
class MessageFeedbackApi(InstalledAppResource):
    @console_ns.expect(console_ns.models[MessageFeedbackPayload.__name__])
    @console_ns.response(200, "Feedback submitted successfully", console_ns.models[ResultResponse.__name__])
    @with_current_user
    @model_validate(MessageFeedbackPayload)
    def post(
        self, req_data: MessageFeedbackPayload, current_user: Account, installed_app: InstalledApp, message_id: UUID
    ):
        app_model = installed_app.app_with_session(session=db.session())
        if app_model is None:

View on GitHub (pinned to ef8544b173)

Solutions

  1. Treat 404 on this endpoint as 'conversation gone' and reset the client to start a new conversation.
  2. Validate the conversation_id belongs to the current user/app by listing conversations first if available.
  3. Clear cached conversation_id on tenant switch or app re-install.
  4. Confirm the conversation_id is a UUID-format string and not truncated.

Example fix

// before: reuse a conversation id that may be stale
const msgs = await get(messagesUrl({ conversation_id: lastConvId }));

// after: reset on 404
try {
  const msgs = await get(messagesUrl({ conversation_id: lastConvId }));
} catch (e) {
  if (e.status === 404 && e.code === undefined) { lastConvId = null; startNewConversation(); }
  else throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate conversation id format and ownership before paging
function validConversationId(v) {
  return typeof v === 'string' && /^[0-9a-fA-F-]{36}$/.test(v);
}
if (!validConversationId(conversationId)) conversationId = null;

Type guard

function isLikelyValidConversationId(value) {
  return typeof value === 'string' && /^[0-9a-fA-F-]{36}$/.test(value);
}

Try / catch

try {
  return await get(messagesUrl(id, { conversation_id }));
} catch (e) {
  if (e.status === 404 && /Conversation Not Exists/.test(e.message)) {
    clearStoredConversationId();
    return get(messagesUrl(id, {})); // start fresh
  }
  throw e;
}

Prevention

When it happens

Trigger: GET /installed-apps/<id>/messages?conversation_id=<cid> where <cid> does not exist, was deleted, belongs to a different app, or belongs to a different user. The service-level error is translated to NotFound at the controller boundary.

Common situations: Stale conversation_id kept in client state after the conversation was deleted; user switched tenants; conversation id copied from another app; retention job purged old conversations.

Related errors


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