langgenius/dify · error · NotFound

Message not found

Error message

Message not found

What it means

HTTP 404 NotFound with body message 'Message not found', raised when MessageService.get_suggested_questions_after_answer raises MessageNotExistsError. The message_id path parameter does not resolve to a message owned by this app/invoke context. This is a clean not-found at the domain boundary, translated from a service error to an HTTP 404.

Source

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

    @with_current_user
    def get(self, current_user: Account, trial_app, message_id):
        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}

View on GitHub (pinned to ef8544b173)

Solutions

  1. Verify the message_id exists for this app via the message list API before calling suggested-questions, or simply treat 404 as 'refresh the conversation'.
  2. If the id came from a stale client store, clear it and re-fetch the current message id from the conversation history endpoint.
  3. Confirm the message was not deleted by an admin/retention policy.

Example fix

// before
const r = await fetch(suggestedUrl)

// after - handle 404 by resetting the conversation
const r = await fetch(suggestedUrl)
if (r.status === 404) { resetConversation(); return }
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the message exists for this app before calling suggested-questions.
const msgs = await fetch(`/console/api/explore/apps/${appId}/chat-messages?conversation_id=${convId}`).then(r => r.json())
const exists = (msgs.data || []).some(m => m.id === messageId)
if (!exists) throw new Error('message not found')

Try / catch

try {
  const r = await fetch(suggestedUrl)
  if (r.status === 404) { resetConversationOrMessage(); return }
} catch (e) { reportToUser(e) }

Prevention

When it happens

Trigger: GET suggested-questions with a message_id that was deleted, belongs to a different app, or was never created (typo, stale client cache, copied URL). Also occurs when the message belongs to a different tenant or the trial app id and message id are mismatched in the URL.

Common situations: Client caches a message id across a conversation reset; the message was hard-deleted by a retention job; the user is testing with a fabricated uuid; the app was re-imported so prior message ids no longer exist.

Related errors


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