Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: get recommend_app categories should not re-order it (#36161)

非法操作a03ee828a358
diff --git a/api/services/recommend_app/remote/remote_retrieval.py b/api/services/recommend_app/remote/remote_retrieval.py
index 5818be04805..0603e4c4826 100644
--- a/api/services/recommend_app/remote/remote_retrieval.py
+++ b/api/services/recommend_app/remote/remote_retrieval.py
@@ -13,7 +13,10 @@ logger = logging.getLogger(__name__)
class RemoteRecommendAppRetrieval(RecommendAppRetrievalBase):
"""
- Retrieval recommended app from dify official
+ Retrieval recommended app from dify official.
+
+ The remote `/apps` payload is already curated for display, including category order.
+ Keep the response order intact so Explore matches the template service.
"""
def get_recommend_app_detail(self, app_id: str):
@@ -64,8 +67,4 @@ class RemoteRecommendAppRetrieval(RecommendAppRetrievalBase):
raise ValueError(f"fetch recommended apps failed, status code: {response.status_code}")
result: dict[str, Any] = response.json()
-
- if "categories" in result:
- result["categories"] = sorted(result["categories"])
-
return result
diff --git a/api/tests/unit_tests/services/recommend_app/test_remote_retrieval.py b/api/tests/unit_tests/services/recommend_app/test_remote_retrieval.py
index e322fbed4c5..c7b86e5743d 100644
--- a/api/tests/unit_tests/services/recommend_app/test_remote_retrieval.py
+++ b/api/tests/unit_tests/services/recommend_app/test_remote_retrieval.py
@@ -85,7 +85,7 @@ class TestFetchFromDifyOfficial:
@patch("services.recommend_app.remote.remote_retrieval.dify_config")
@patch("services.recommend_app.remote.remote_retrieval.httpx.get")
- def test_apps_returns_sorted_categories_on_200(self, mock_get, mock_config):
+ def test_apps_preserves_remote_categories_order_on_200(self, mock_get, mock_config):
mock_config.HOSTED_FETCH_APP_TEMPLATES_REMOTE_DOMAIN = "https://example.com"
mock_response = MagicMock(status_code=200)
mock_response.json.return_value = {
@@ -96,7 +96,7 @@ class TestFetchFromDifyOfficial:
result = RemoteRecommendAppRetrieval.fetch_recommended_apps_from_dify_official("en-US")
- assert result["categories"] == ["agent", "chat", "writing"]
+ assert result["categories"] == ["writing", "agent", "chat"]
@patch("services.recommend_app.remote.remote_retrieval.dify_config")
@patch("services.recommend_app.remote.remote_retrieval.httpx.get")