langgenius/dify · warning · NotFound

Last Conversation Not Exists.

Error message

Last Conversation Not Exists.

What it means

NotFound (HTTP 404, werkzeug) with message 'Last Conversation Not Exists.' is raised in ConversationListApi.get when WebConversationService.pagination_by_last_id throws LastConversationNotExistsError. This happens when the 'last_id' query parameter references a conversation that does not exist (e.g. was deleted) — the cursor-based pagination cannot find the anchor conversation to page after.

Source

Thrown at api/controllers/console/explore/conversation.py:101

                    limit=args.limit,
                    invoke_from=InvokeFrom.EXPLORE,
                    pinned=args.pinned,
                )
                adapter = TypeAdapter(SimpleConversation)
                conversations = [
                    adapter.validate_python(
                        ConversationResponseSource(item, session=session),
                        from_attributes=True,
                    )
                    for item in pagination.data
                ]
                return ConversationInfiniteScrollPagination(
                    limit=pagination.limit,
                    has_more=pagination.has_more,
                    data=conversations,
                ).model_dump(mode="json")
        except LastConversationNotExistsError:
            raise NotFound("Last Conversation Not Exists.")


@console_ns.route(
    "/installed-apps/<uuid:installed_app_id>/conversations/<uuid:c_id>",
    endpoint="installed_app_conversation",
)
class ConversationApi(InstalledAppResource):
    @console_ns.response(204, "Conversation deleted successfully")
    @with_current_user
    def delete(self, current_user: Account, installed_app: InstalledApp, c_id: UUID):
        app_model = installed_app.app_with_session(session=db.session())
        if app_model is None:
            raise AppUnavailableError()
        app_mode = AppMode.value_of(app_model.mode)
        if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:
            raise NotChatAppError()

        conversation_id = str(c_id)

View on GitHub (pinned to ef8544b173)

Solutions

  1. Retry the request without the last_id parameter to start pagination from the most recent conversation.
  2. If the client caches last_id values, clear the cached cursor and restart pagination from the beginning.
  3. Ensure the last_id passed is from the current user's own conversation list.

Example fix

// before: keep using a stale cursor after conversations are deleted
GET /conversations?last_id=<deleted_conv_id>
// after: restart from the top on 404
try { return await getConversations(lastId); }
catch (e) { if (e.status===404) return await getConversations(null); throw e; }
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const page = await listConversations(installedAppId, lastId);
} catch (e) {
  if (e.status === 404 && e.message?.includes('Last Conversation')) {
    // cursor anchor is gone — restart from the beginning
    const freshPage = await listConversations(installedAppId, null);
    return freshPage;
  }
  throw e;
}

Prevention

When it happens

Trigger: GET /console/explore/installed-apps/<id>/conversations?last_id=<uuid> where the conversation with that UUID was deleted, belongs to a different user, or never existed. The pagination logic uses last_id as a cursor anchor and fails when it cannot locate it.

Common situations: The user paginated, then deleted the conversation that was the cursor; the last_id was copied from a different user's session; the conversation expired or was cleaned up by a retention policy; a stale URL was revisited after the anchor conversation was removed.

Related errors


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