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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
chore: remove console feedback export endpoint (#43751)
非法操作d4111302c028
diff --git a/api/controllers/console/app/message.py b/api/controllers/console/app/message.pyindex 12d2746b364..61e6b87a06b 100644--- a/api/controllers/console/app/message.py+++ b/api/controllers/console/app/message.py@@ -1,6 +1,5 @@import loggingfrom http import HTTPStatus-from typing import Literalfrom uuid import UUIDfrom flask_restx import Resource@@ -10,7 +9,7 @@ from sqlalchemy.orm import Sessionfrom werkzeug.exceptions import HTTPException, InternalServerError, NotFound, Unauthorizedfrom controllers.common.controller_schemas import MessageFeedbackPayload as _MessageFeedbackPayloadBase-from controllers.common.fields import SimpleResultResponse, TextFileResponse+from controllers.common.fields import SimpleResultResponsefrom controllers.common.rbac import AgentId, PlainApp, RBACCheckfrom controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_modelsfrom controllers.common.session import with_session@@ -96,27 +95,6 @@ class MessageFeedbackPayload(_MessageFeedbackPayloadBase):return uuid_value(value)-class FeedbackExportQuery(BaseModel):- from_source: Literal["user", "admin"] | None = Field(default=None, description="Filter by feedback source")- rating: Literal["like", "dislike"] | None = Field(default=None, description="Filter by rating")- has_comment: bool | None = Field(default=None, description="Only include feedback with comments")- start_date: str | None = Field(default=None, description="Start date (YYYY-MM-DD)")- end_date: str | None = Field(default=None, description="End date (YYYY-MM-DD)")- format: Literal["csv", "json"] = Field(default="csv", description="Export format")-- @field_validator("has_comment", mode="before")- @classmethod- def parse_bool(cls, value: bool | str | None) -> bool | None:- if isinstance(value, bool) or value is None:- return value- lowered = value.lower()- if lowered in {"true", "1", "yes", "on"}:- return True- if lowered in {"false", "0", "no", "off"}:- return False- raise ValueError("has_comment must be a boolean value")--class AnnotationCountResponse(ResponseModel):count: int = Field(description="Number of annotations")@@ -139,7 +117,6 @@ register_schema_models(console_ns,ChatMessagesQuery,MessageFeedbackPayload,- FeedbackExportQuery,)register_response_schema_models(console_ns,@@ -148,7 +125,6 @@ register_response_schema_models(MessageDetailResponse,MessageInfiniteScrollPaginationResponse,SimpleResultResponse,- TextFileResponse,)@@ -354,50 +330,6 @@ class AgentMessageSuggestedQuestionApi(Resource):)-@console_ns.route("/apps/<uuid:app_id>/feedbacks/export")-class MessageFeedbackExportApi(Resource):- @console_ns.doc("export_feedbacks")- @console_ns.doc(description="Export user feedback data for Google Sheets")- @console_ns.response(- 200,- "Feedback data exported successfully",- console_ns.models[TextFileResponse.__name__],- )- @console_ns.doc(params={"app_id": "Application ID", **query_params_from_model(FeedbackExportQuery)})- @console_ns.response(400, "Invalid parameters")- @console_ns.response(500, "Internal server error")- @setup_required- @login_required- @account_initialization_required- @rbac_permission_required(RBACCheck(RBACPermission.APP_VIEW_LAYOUT, PlainApp()))- @get_app_model- @model_validate(FeedbackExportQuery)- def get(self, req_data: FeedbackExportQuery, app_model: App):-- # Import the service function- from services.feedback_service import FeedbackService-- try:- export_data = FeedbackService.export_feedbacks(- app_model.id,- session=db.session(),- from_source=req_data.from_source,- rating=req_data.rating,- has_comment=req_data.has_comment,- start_date=req_data.start_date,- end_date=req_data.end_date,- format_type=req_data.format,- )- return export_data-- except ValueError as e:- logger.exception("Parameter validation error in feedback export")- return {"error": f"Parameter validation error: {str(e)}"}, 400- except Exception as e:- logger.exception("Error exporting feedback data")- raise InternalServerError(str(e))--@console_ns.route("/apps/<uuid:app_id>/messages/<uuid:message_id>")class MessageApi(Resource):@console_ns.doc("get_message")diff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.mdindex 50264af47c2..48d5db25c49 100644--- a/api/openapi/markdown/console-openapi.md+++ b/api/openapi/markdown/console-openapi.md@@ -2745,29 +2745,6 @@ Create or update message feedback (like/dislike)| 403 | Insufficient permissions | || 404 | Message not found | |-### [GET] /apps/{app_id}/feedbacks/export-Export user feedback data for Google Sheets--#### Parameters--| Name | Located in | Description | Required | Schema |-| ---- | ---------- | ----------- | -------- | ------ |-| app_id | path | Application ID | Yes | string (uuid) |-| end_date | query | End date (YYYY-MM-DD) | No | string |-| format | query | Export format | No | string, <br>**Available values:** "csv", "json", <br>**Default:** csv |-| from_source | query | Filter by feedback source | No | string, <br>**Available values:** "admin", "user" |-| has_comment | query | Only include feedback with comments | No | boolean |-| rating | query | Filter by rating | No | string, <br>**Available values:** "dislike", "like" |-| start_date | query | Start date (YYYY-MM-DD) | No | string |--#### Responses--| Code | Description | Schema |-| ---- | ----------- | ------ |-| 200 | Feedback data exported successfully | **application/json**: [TextFileResponse](#textfileresponse)<br> |-| 400 | Invalid parameters | |-| 500 | Internal server error | |-### [POST] /apps/{app_id}/iconUpdate application icon@@ -19638,17 +19615,6 @@ Effective feature availability and limits for the current workspace.| from_source | string | | Yes || rating | string | | Yes |-#### FeedbackExportQuery--| Name | Type | Description | Required |-| ---- | ---- | ----------- | -------- |-| end_date | string | End date (YYYY-MM-DD) | No |-| format | string, <br>**Available values:** "csv", "json", <br>**Default:** csv | Export format<br>*Enum:* `"csv"`, `"json"` | No |-| from_source | string, <br>**Available values:** "admin", "user" | Filter by feedback source | No |-| has_comment | boolean | Only include feedback with comments | No |-| rating | string, <br>**Available values:** "dislike", "like" | Filter by rating | No |-| start_date | string | Start date (YYYY-MM-DD) | No |-#### FeedbackStat| Name | Type | Description | Required |diff --git a/api/services/feedback_service.py b/api/services/feedback_service.pydeleted file mode 100644index af231394953..00000000000--- a/api/services/feedback_service.py+++ /dev/null@@ -1,189 +0,0 @@-import csv-import io-import json-from datetime import datetime, timedelta--from flask import Response-from sqlalchemy import or_, select-from sqlalchemy.orm import Session--from models.enums import FeedbackRating-from models.model import Account, App, Conversation, Message, MessageFeedback---class FeedbackService:- @staticmethod- def export_feedbacks(- app_id: str,- *,- session: Session,- from_source: str | None = None,- rating: str | None = None,- has_comment: bool | None = None,- start_date: str | None = None,- end_date: str | None = None,- format_type: str = "csv",- ):- """- Export feedback data with message details for analysis-- Args:- app_id: Application ID- session: Database session used to run the export query- from_source: Filter by feedback source ('user' or 'admin')- rating: Filter by rating ('like' or 'dislike')- has_comment: Only include feedback with comments- start_date: Start date filter (YYYY-MM-DD)- end_date: End date filter (YYYY-MM-DD)- format_type: Export format ('csv' or 'json')- """-- # Validate format early to avoid hitting DB when unnecessary- fmt = (format_type or "csv").lower()- if fmt not in {"csv", "json"}:- raise ValueError(f"Unsupported format: {format_type}")-- # Build base query- stmt = (- select(MessageFeedback, Message, Conversation, App, Account)- .join(Message, MessageFeedback.message_id == Message.id)- .join(Conversation, MessageFeedback.conversation_id == Conversation.id)- .join(App, MessageFeedback.app_id == App.id)- .outerjoin(Account, MessageFeedback.from_account_id == Account.id)- .where(MessageFeedback.app_id == app_id)- )-- # Apply filters- if from_source:- stmt = stmt.where(MessageFeedback.from_source == from_source)-- if rating:- stmt = stmt.where(MessageFeedback.rating == rating)-- if has_comment is not None:- if has_comment:- stmt = stmt.where(MessageFeedback.content.isnot(None), MessageFeedback.content != "")- else:- stmt = stmt.where(or_(MessageFeedback.content.is_(None), MessageFeedback.content == ""))-- if start_date:- try:- start_dt = datetime.strptime(start_date, "%Y-%m-%d")- stmt = stmt.where(MessageFeedback.created_at >= start_dt)- except ValueError:- raise ValueError(f"Invalid start_date format: {start_date}. Use YYYY-MM-DD")-- if end_date:- try:- end_dt = datetime.strptime(end_date, "%Y-%m-%d") + timedelta(days=1)- stmt = stmt.where(MessageFeedback.created_at < end_dt)- except ValueError:- raise ValueError(f"Invalid end_date format: {end_date}. Use YYYY-MM-DD")-- # Order by creation date (newest first)- stmt = stmt.order_by(MessageFeedback.created_at.desc())-- # Execute query- results = session.execute(stmt).all()-- # Prepare data for export- export_data = []- for feedback, message, conversation, app, account in results:- # Get the user query from the message- user_query = message.query or message.inputs_with_session(session=session).get("query", "")-- # Format the feedback data- feedback_record = {- "feedback_id": str(feedback.id),- "app_name": app.name,- "app_id": str(app.id),- "conversation_id": str(conversation.id),- "conversation_name": conversation.name or "",- "message_id": str(message.id),- "user_query": user_query,- "ai_response": message.answer[:500] + "..."- if len(message.answer) > 500- else message.answer, # Truncate long responses- "feedback_rating": "👍" if feedback.rating == FeedbackRating.LIKE else "👎",- "feedback_rating_raw": feedback.rating,- "feedback_comment": feedback.content or "",- "feedback_source": feedback.from_source,- "feedback_date": feedback.created_at.strftime("%Y-%m-%d %H:%M:%S"),- "message_date": message.created_at.strftime("%Y-%m-%d %H:%M:%S"),- "from_account_name": account.name if account else "",- "from_end_user_id": str(feedback.from_end_user_id) if feedback.from_end_user_id else "",- "has_comment": "Yes" if feedback.content and feedback.content.strip() else "No",- }- export_data.append(feedback_record)-- # Export based on format- if fmt == "csv":- return FeedbackService._export_csv(export_data, app_id)- else: # fmt == "json"- return FeedbackService._export_json(export_data, app_id)-- @staticmethod- def _export_csv(data, app_id):- """Export data as CSV"""- if not data:- pass # allow empty CSV with headers only-- # Create CSV in memory- output = io.StringIO()-- # Define headers- headers = [- "feedback_id",- "app_name",- "app_id",- "conversation_id",- "conversation_name",- "message_id",- "user_query",- "ai_response",- "feedback_rating",- "feedback_rating_raw",- "feedback_comment",- "feedback_source",- "feedback_date",- "message_date",- "from_account_name",- "from_end_user_id",- "has_comment",- ]-- writer = csv.DictWriter(output, fieldnames=headers)- writer.writeheader()- writer.writerows(data)-- # Create response without requiring app context- response = Response(output.getvalue(), mimetype="text/csv; charset=utf-8-sig")- response.headers["Content-Disposition"] = (- f"attachment; filename=dify_feedback_export_{app_id}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"- )-- return response-- @staticmethod- def _export_json(data, app_id):- """Export data as JSON"""- response_data = {- "export_info": {- "app_id": app_id,- "export_date": datetime.now().isoformat(),- "total_records": len(data),- "data_source": "dify_feedback_export",- },- "feedback_data": data,- }-- # Create response without requiring app context- response = Response(- json.dumps(response_data, ensure_ascii=False, indent=2),- mimetype="application/json; charset=utf-8",- )- response.headers["Content-Disposition"] = (- f"attachment; filename=dify_feedback_export_{app_id}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json"- )-- return responsediff --git a/api/tests/integration_tests/controllers/console/app/test_feedback_api_basic.py b/api/tests/integration_tests/controllers/console/app/test_feedback_api_basic.pyindex b164e4f887d..b823f2bad98 100644--- a/api/tests/integration_tests/controllers/console/app/test_feedback_api_basic.py+++ b/api/tests/integration_tests/controllers/console/app/test_feedback_api_basic.py@@ -8,22 +8,6 @@ from flask.testing import FlaskClientclass TestFeedbackApiBasic:"""Basic tests for feedback API endpoints."""- def test_feedback_export_endpoint_exists(self, test_client: FlaskClient, auth_header):- """Test that feedback export endpoint exists and handles basic requests."""-- app_id = str(uuid.uuid4())-- # Test endpoint exists (even if it fails, it should return 500 or 403, not 404)- response = test_client.get(- f"/console/api/apps/{app_id}/feedbacks/export", headers=auth_header, query_string={"format": "csv"}- )-- # Should not return 404 (endpoint exists)- assert response.status_code != 404-- # Should return authentication or permission error- assert response.status_code in [401, 403, 500] # 500 if app doesn't exist, 403 if no permission-def test_feedback_summary_endpoint_exists(self, test_client: FlaskClient, auth_header):"""Test that feedback summary endpoint exists and handles basic requests."""@@ -37,70 +21,3 @@ class TestFeedbackApiBasic:# Should return authentication or permission errorassert response.status_code in [401, 403, 500]-- def test_feedback_export_invalid_format(self, test_client: FlaskClient, auth_header):- """Test feedback export endpoint with invalid format parameter."""-- app_id = str(uuid.uuid4())-- # Test with invalid format- response = test_client.get(- f"/console/api/apps/{app_id}/feedbacks/export",- headers=auth_header,- query_string={"format": "invalid_format"},- )-- # Should not return 404- assert response.status_code != 404-- def test_feedback_export_with_filters(self, test_client: FlaskClient, auth_header):- """Test feedback export endpoint with various filter parameters."""-- app_id = str(uuid.uuid4())-- # Test with various filter combinations- filter_params = [- {"from_source": "user"},- {"rating": "like"},- {"has_comment": True},- {"start_date": "2024-01-01"},- {"end_date": "2024-12-31"},- {"format": "json"},- {- "from_source": "admin",- "rating": "dislike",- "has_comment": True,- "start_date": "2024-01-01",- "end_date": "2024-12-31",- "format": "csv",- },- ]-- for params in filter_params:- response = test_client.get(- f"/console/api/apps/{app_id}/feedbacks/export", headers=auth_header, query_string=params- )-- # Should not return 404- assert response.status_code != 404-- def test_feedback_export_invalid_dates(self, test_client: FlaskClient, auth_header):- """Test feedback export endpoint with invalid date formats."""-- app_id = str(uuid.uuid4())-- # Test with invalid date formats- invalid_dates = [- {"start_date": "invalid-date"},- {"end_date": "not-a-date"},- {"start_date": "2024-13-01"}, # Invalid month- {"end_date": "2024-12-32"}, # Invalid day- ]-- for params in invalid_dates:- response = test_client.get(- f"/console/api/apps/{app_id}/feedbacks/export", headers=auth_header, query_string=params- )-- # Should not return 404- assert response.status_code != 404diff --git a/api/tests/integration_tests/controllers/console/app/test_feedback_export_api.py b/api/tests/integration_tests/controllers/console/app/test_feedback_export_api.pydeleted file mode 100644index b382814e3c0..00000000000--- a/api/tests/integration_tests/controllers/console/app/test_feedback_export_api.py+++ /dev/null@@ -1,344 +0,0 @@-"""Integration tests for Feedback Export API endpoints."""--import json-import uuid-from datetime import datetime-from types import SimpleNamespace-from unittest import mock--import pytest-from flask.testing import FlaskClient--from controllers.console.app import message as message_api-from controllers.console.app import wraps-from libs.datetime_utils import naive_utc_now-from models import App, Tenant-from models.account import Account, TenantAccountJoin, TenantAccountRole-from models.enums import AppStatus, FeedbackFromSource, FeedbackRating-from models.model import AppMode, MessageFeedback-from services.feedback_service import FeedbackService---class TestFeedbackExportApi:- """Test feedback export API endpoints."""-- @pytest.fixture- def mock_app_model(self):- """Create a mock App model for testing."""- app = App()- app.id = str(uuid.uuid4())- app.mode = AppMode.CHAT- app.tenant_id = str(uuid.uuid4())- app.status = AppStatus.NORMAL- app.name = "Test App"- return app-- @pytest.fixture- def mock_account(self, monkeypatch: pytest.MonkeyPatch):- """Create a mock Account for testing."""- account = Account(- name="Test User",- email="[email protected]",- )- account.last_active_at = naive_utc_now()- account.created_at = naive_utc_now()- account.updated_at = naive_utc_now()- account.id = str(uuid.uuid4())-- # Create mock tenant- tenant = Tenant(name="Test Tenant")- tenant.id = str(uuid.uuid4())-- mock_session_instance = mock.Mock()-- mock_tenant_join = TenantAccountJoin(role=TenantAccountRole.OWNER)- monkeypatch.setattr(mock_session_instance, "scalar", mock.Mock(return_value=mock_tenant_join))-- mock_scalars_result = mock.Mock()- mock_scalars_result.one.return_value = tenant- monkeypatch.setattr(mock_session_instance, "scalars", mock.Mock(return_value=mock_scalars_result))-- account.set_current_tenant_with_session(tenant, session=mock_session_instance)- return account-- @pytest.fixture- def sample_feedback_data(self):- """Create sample feedback data for testing."""- app_id = str(uuid.uuid4())- conversation_id = str(uuid.uuid4())- message_id = str(uuid.uuid4())-- # Mock feedback data- user_feedback = MessageFeedback(- id=str(uuid.uuid4()),- app_id=app_id,- conversation_id=conversation_id,- message_id=message_id,- rating=FeedbackRating.LIKE,- from_source=FeedbackFromSource.USER,- content=None,- from_end_user_id=str(uuid.uuid4()),- from_account_id=None,- created_at=naive_utc_now(),- )-- admin_feedback = MessageFeedback(- id=str(uuid.uuid4()),- app_id=app_id,- conversation_id=conversation_id,- message_id=message_id,- rating=FeedbackRating.DISLIKE,- from_source=FeedbackFromSource.ADMIN,- content="The response was not helpful",- from_end_user_id=None,- from_account_id=str(uuid.uuid4()),- created_at=naive_utc_now(),- )-- # Mock message and conversation- mock_message = SimpleNamespace(- id=message_id,- conversation_id=conversation_id,- query="What is the weather today?",- answer="It's sunny and 25 degrees outside.",- inputs={"query": "What is the weather today?"},- created_at=naive_utc_now(),- )-- mock_conversation = SimpleNamespace(id=conversation_id, name="Weather Conversation", app_id=app_id)-- mock_app = SimpleNamespace(id=app_id, name="Weather App")-- return {- "user_feedback": user_feedback,- "admin_feedback": admin_feedback,- "message": mock_message,- "conversation": mock_conversation,- "app": mock_app,- }-- @pytest.mark.parametrize(- ("role", "status"),- [- (TenantAccountRole.OWNER, 200),- (TenantAccountRole.ADMIN, 200),- (TenantAccountRole.EDITOR, 200),- (TenantAccountRole.NORMAL, 403),- (TenantAccountRole.DATASET_OPERATOR, 403),- ],- )- def test_feedback_export_permissions(- self,- test_client: FlaskClient,- auth_header,- monkeypatch: pytest.MonkeyPatch,- mock_app_model,- mock_account,- role: TenantAccountRole,- status: int,- ):- """Test feedback export endpoint permissions."""-- # Setup mocks- mock_load_app_model = mock.Mock(return_value=mock_app_model)- monkeypatch.setattr(wraps, "_load_app_model_from_scoped_session", mock_load_app_model)-- mock_export_feedbacks = mock.Mock(return_value="mock csv response")- monkeypatch.setattr(FeedbackService, "export_feedbacks", mock_export_feedbacks)-- monkeypatch.setattr(message_api, "current_user", mock_account)-- # Set user role- mock_account.role = role-- response = test_client.get(- f"/console/api/apps/{mock_app_model.id}/feedbacks/export",- headers=auth_header,- query_string={"format": "csv"},- )-- assert response.status_code == status-- if status == 200:- mock_export_feedbacks.assert_called_once()-- def test_feedback_export_csv_format(- self,- test_client: FlaskClient,- auth_header,- monkeypatch: pytest.MonkeyPatch,- mock_app_model,- mock_account,- sample_feedback_data,- ):- """Test feedback export in CSV format."""-- # Setup mocks- mock_load_app_model = mock.Mock(return_value=mock_app_model)- monkeypatch.setattr(wraps, "_load_app_model_from_scoped_session", mock_load_app_model)-- # Create mock CSV response- mock_csv_content = (- "feedback_id,app_name,conversation_id,user_query,ai_response,feedback_rating,feedback_comment\n"- )- mock_csv_content += f"{sample_feedback_data['user_feedback'].id},{sample_feedback_data['app'].name},"- mock_csv_content += f"{sample_feedback_data['conversation'].id},{sample_feedback_data['message'].query},"- mock_csv_content += f"{sample_feedback_data['message'].answer},👍,\n"-- mock_response = mock.Mock()- mock_response.headers = {"Content-Type": "text/csv; charset=utf-8-sig"}- mock_response.data = mock_csv_content.encode("utf-8")-- mock_export_feedbacks = mock.Mock(return_value=mock_response)- monkeypatch.setattr(FeedbackService, "export_feedbacks", mock_export_feedbacks)-- monkeypatch.setattr(message_api, "current_user", mock_account)-- response = test_client.get(- f"/console/api/apps/{mock_app_model.id}/feedbacks/export",- headers=auth_header,- query_string={"format": "csv", "from_source": "user"},- )-- assert response.status_code == 200- assert "text/csv" in response.content_type-- def test_feedback_export_json_format(- self,- test_client: FlaskClient,- auth_header,- monkeypatch: pytest.MonkeyPatch,- mock_app_model,- mock_account,- sample_feedback_data,- ):- """Test feedback export in JSON format."""-- # Setup mocks- mock_load_app_model = mock.Mock(return_value=mock_app_model)- monkeypatch.setattr(wraps, "_load_app_model_from_scoped_session", mock_load_app_model)-- mock_json_response = {- "export_info": {- "app_id": mock_app_model.id,- "export_date": datetime.now().isoformat(),- "total_records": 2,- "data_source": "dify_feedback_export",- },- "feedback_data": [- {- "feedback_id": sample_feedback_data["user_feedback"].id,- "feedback_rating": "👍",- "feedback_rating_raw": "like",- "feedback_comment": "",- }- ],- }-- mock_response = mock.Mock()- mock_response.headers = {"Content-Type": "application/json; charset=utf-8"}- mock_response.data = json.dumps(mock_json_response).encode("utf-8")-- mock_export_feedbacks = mock.Mock(return_value=mock_response)- monkeypatch.setattr(FeedbackService, "export_feedbacks", mock_export_feedbacks)-- monkeypatch.setattr(message_api, "current_user", mock_account)-- response = test_client.get(- f"/console/api/apps/{mock_app_model.id}/feedbacks/export",- headers=auth_header,- query_string={"format": "json"},- )-- assert response.status_code == 200- assert "application/json" in response.content_type-- def test_feedback_export_with_filters(- self, test_client: FlaskClient, auth_header, monkeypatch: pytest.MonkeyPatch, mock_app_model, mock_account- ):- """Test feedback export with various filters."""-- # Setup mocks- mock_load_app_model = mock.Mock(return_value=mock_app_model)- monkeypatch.setattr(wraps, "_load_app_model_from_scoped_session", mock_load_app_model)-- mock_export_feedbacks = mock.Mock(return_value="mock filtered response")- monkeypatch.setattr(FeedbackService, "export_feedbacks", mock_export_feedbacks)-- monkeypatch.setattr(message_api, "current_user", mock_account)-- # Test with multiple filters- response = test_client.get(- f"/console/api/apps/{mock_app_model.id}/feedbacks/export",- headers=auth_header,- query_string={- "from_source": "user",- "rating": "dislike",- "has_comment": True,- "start_date": "2024-01-01",- "end_date": "2024-12-31",- "format": "csv",- },- )-- assert response.status_code == 200-- # Verify service was called with correct parameters- mock_export_feedbacks.assert_called_once_with(- mock.ANY,- app_id=mock_app_model.id,- from_source=FeedbackFromSource.USER,- rating=FeedbackRating.DISLIKE,- has_comment=True,- start_date="2024-01-01",- end_date="2024-12-31",- format_type="csv",- )-- def test_feedback_export_invalid_date_format(- self, test_client: FlaskClient, auth_header, monkeypatch: pytest.MonkeyPatch, mock_app_model, mock_account- ):- """Test feedback export with invalid date format."""-- # Setup mocks- mock_load_app_model = mock.Mock(return_value=mock_app_model)- monkeypatch.setattr(wraps, "_load_app_model_from_scoped_session", mock_load_app_model)-- # Mock the service to raise ValueError for invalid date- mock_export_feedbacks = mock.Mock(side_effect=ValueError("Invalid date format"))- monkeypatch.setattr(FeedbackService, "export_feedbacks", mock_export_feedbacks)-- monkeypatch.setattr(message_api, "current_user", mock_account)-- response = test_client.get(- f"/console/api/apps/{mock_app_model.id}/feedbacks/export",- headers=auth_header,- query_string={"start_date": "invalid-date", "format": "csv"},- )-- assert response.status_code == 400- response_json = response.get_json()- assert "Parameter validation error" in response_json["error"]-- def test_feedback_export_server_error(- self, test_client: FlaskClient, auth_header, monkeypatch: pytest.MonkeyPatch, mock_app_model, mock_account- ):- """Test feedback export with server error."""-- # Setup mocks- mock_load_app_model = mock.Mock(return_value=mock_app_model)- monkeypatch.setattr(wraps, "_load_app_model_from_scoped_session", mock_load_app_model)-- # Mock the service to raise an exception- mock_export_feedbacks = mock.Mock(side_effect=Exception("Database connection failed"))- monkeypatch.setattr(FeedbackService, "export_feedbacks", mock_export_feedbacks)-- monkeypatch.setattr(message_api, "current_user", mock_account)-- response = test_client.get(- f"/console/api/apps/{mock_app_model.id}/feedbacks/export",- headers=auth_header,- query_string={"format": "csv"},- )-- assert response.status_code == 500diff --git a/api/tests/test_containers_integration_tests/controllers/console/app/test_message.py b/api/tests/test_containers_integration_tests/controllers/console/app/test_message.pyindex 20d81274ac1..840619fa261 100644--- a/api/tests/test_containers_integration_tests/controllers/console/app/test_message.py+++ b/api/tests/test_containers_integration_tests/controllers/console/app/test_message.py@@ -10,7 +10,7 @@ from flask.testing import FlaskClientfrom sqlalchemy import selectfrom sqlalchemy.orm import Session-from controllers.console.app.message import ChatMessagesQuery, FeedbackExportQuery, MessageFeedbackPayload+from controllers.console.app.message import ChatMessagesQuery, MessageFeedbackPayloadfrom controllers.console.app.message import attach_message_extra_contents as _attach_message_extra_contentsfrom core.errors.error import ModelCurrentlyNotSupportError, ProviderTokenNotInitError, QuotaExceededErrorfrom libs.datetime_utils import naive_utc_now@@ -103,16 +103,6 @@ class TestMessageValidators:== "123e4567-e89b-12d3-a456-426614174000")- def test_feedback_export_validators(self) -> None:- assert FeedbackExportQuery.parse_bool(None) is None- assert FeedbackExportQuery.parse_bool(True) is True- assert FeedbackExportQuery.parse_bool("1") is True- assert FeedbackExportQuery.parse_bool("0") is False- assert FeedbackExportQuery.parse_bool("off") is False-- with pytest.raises(ValueError):- FeedbackExportQuery.parse_bool("invalid")-def test_chat_message_list_not_found(db_session_with_containers: Session,@@ -305,23 +295,6 @@ def test_message_suggested_questions_errors(assert payload["code"] == expected_code-def test_message_feedback_export_success(- db_session_with_containers: Session,- test_client_with_containers: FlaskClient,-) -> None:- account, tenant = create_console_account_and_tenant(db_session_with_containers)- app = create_console_app(db_session_with_containers, tenant.id, account.id, AppMode.CHAT)-- with patch("services.feedback_service.FeedbackService.export_feedbacks", return_value={"exported": True}):- response = test_client_with_containers.get(- f"/console/api/apps/{app.id}/feedbacks/export",- headers=authenticate_console_client(test_client_with_containers, account),- )-- assert response.status_code == 200- assert response.get_json() == {"exported": True}--def test_message_api_get_success(db_session_with_containers: Session,test_client_with_containers: FlaskClient,diff --git a/api/tests/unit_tests/controllers/console/app/test_message_api.py b/api/tests/unit_tests/controllers/console/app/test_message_api.pyindex b9530a5c8d8..d21973425ca 100644--- a/api/tests/unit_tests/controllers/console/app/test_message_api.py+++ b/api/tests/unit_tests/controllers/console/app/test_message_api.py@@ -298,49 +298,6 @@ def test_message_feedback_payload_no_rating(app: Flask, monkeypatch: pytest.Monkassert payload.rating is None-def test_feedback_export_query_defaults(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:- """Test FeedbackExportQuery with default format."""- query = message_module.FeedbackExportQuery()- assert query.format == "csv"- assert query.from_source is None---def test_feedback_export_query_json_format(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:- """Test FeedbackExportQuery with JSON format."""- query = message_module.FeedbackExportQuery(format="json")- assert query.format == "json"---def test_feedback_export_query_has_comment_true(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:- """Test FeedbackExportQuery with has_comment as true string."""- query = message_module.FeedbackExportQuery(has_comment="true")- assert query.has_comment is True---def test_feedback_export_query_has_comment_false(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:- """Test FeedbackExportQuery with has_comment as false string."""- query = message_module.FeedbackExportQuery(has_comment="false")- assert query.has_comment is False---def test_feedback_export_query_has_comment_1(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:- """Test FeedbackExportQuery with has_comment as 1."""- query = message_module.FeedbackExportQuery(has_comment="1")- assert query.has_comment is True---def test_feedback_export_query_has_comment_0(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:- """Test FeedbackExportQuery with has_comment as 0."""- query = message_module.FeedbackExportQuery(has_comment="0")- assert query.has_comment is False---def test_feedback_export_query_rating_filter(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:- """Test FeedbackExportQuery with rating filter."""- query = message_module.FeedbackExportQuery(rating="like")- assert query.rating == "like"--def test_annotation_count_response(app: Flask, monkeypatch: pytest.MonkeyPatch) -> None:"""Test AnnotationCountResponse creation."""response = message_module.AnnotationCountResponse(count=10)diff --git a/api/tests/unit_tests/pyrefly.toml b/api/tests/unit_tests/pyrefly.tomlindex af4233b4e82..39b0dd20447 100644--- a/api/tests/unit_tests/pyrefly.toml+++ b/api/tests/unit_tests/pyrefly.toml@@ -768,7 +768,6 @@ project-excludes = ["services/test_external_dataset_service.py","services/test_feature_service_human_input_email_delivery.py","services/test_feature_service_vector_space.py",- "services/test_feedback_service.py","services/test_file_service.py","services/test_human_input_delivery_test_service.py","services/test_human_input_file_upload_service.py",diff --git a/api/tests/unit_tests/services/test_feedback_service.py b/api/tests/unit_tests/services/test_feedback_service.pydeleted file mode 100644index 8e2899e4211..00000000000--- a/api/tests/unit_tests/services/test_feedback_service.py+++ /dev/null@@ -1,264 +0,0 @@-"""Unit tests for feedback exports using SQLite-backed ORM rows.--The export query joins five tables and applies its filters in SQL, so these tests-use a real SQLite session instead of stubbing ``Session.execute`` results.-"""--import json-from datetime import datetime-from decimal import Decimal-from typing import TypedDict--import pytest-from sqlalchemy.orm import Session--from models.account import Account-from models.enums import FeedbackFromSource, FeedbackRating-from models.model import App, AppMode, Conversation, ConversationFromSource, IconType, Message, MessageFeedback-from services.feedback_service import FeedbackService--APP_ID = "11111111-1111-1111-1111-111111111111"-TENANT_ID = "22222222-2222-2222-2222-222222222222"-CONVERSATION_ID = "33333333-3333-3333-3333-333333333333"-MESSAGE_ID = "44444444-4444-4444-4444-444444444444"-ACCOUNT_ID = "55555555-5555-5555-5555-555555555555"-END_USER_ID = "66666666-6666-6666-6666-666666666666"---class FeedbackSample(TypedDict):- app: App- conversation: Conversation- message: Message- user_feedback: MessageFeedback- admin_feedback: MessageFeedback---def sample_data(sqlite_session: Session) -> FeedbackSample:- """Persist a complete user/admin feedback graph for export queries."""-- app = App(- tenant_id=TENANT_ID,- name="Test App",- description="",- mode=AppMode.CHAT,- icon_type=IconType.EMOJI,- icon="🤖",- icon_background="#FFFFFF",- enable_site=False,- enable_api=False,- max_active_requests=0,- )- app.id = APP_ID- conversation = Conversation(- app_id=APP_ID,- mode=AppMode.CHAT,- name="Test Conversation",- from_source=ConversationFromSource.API,- from_end_user_id=END_USER_ID,- )- conversation.id = CONVERSATION_ID- conversation._inputs = {}- message = Message(- app_id=APP_ID,- conversation_id=CONVERSATION_ID,- query="What is AI?",- message={"role": "user", "content": "What is AI?"},- answer="AI is artificial intelligence.",- message_unit_price=Decimal(0),- answer_unit_price=Decimal(0),- currency="USD",- from_source=ConversationFromSource.API,- from_end_user_id=END_USER_ID,- created_at=datetime(2024, 1, 1, 10, 0, 0),- )- message.id = MESSAGE_ID- message._inputs = {"query": "What is AI?"}- account = Account(name="Admin User", email="[email protected]")- account.id = ACCOUNT_ID- user_feedback = MessageFeedback(- app_id=APP_ID,- conversation_id=CONVERSATION_ID,- message_id=MESSAGE_ID,- rating=FeedbackRating.LIKE,- from_source=FeedbackFromSource.USER,- content="Great answer!",- from_end_user_id=END_USER_ID,- )- user_feedback.created_at = datetime(2024, 1, 1, 10, 5, 0)- admin_feedback = MessageFeedback(- app_id=APP_ID,- conversation_id=CONVERSATION_ID,- message_id=MESSAGE_ID,- rating=FeedbackRating.DISLIKE,- from_source=FeedbackFromSource.ADMIN,- content="Could be more detailed",- from_account_id=ACCOUNT_ID,- )- admin_feedback.created_at = datetime(2024, 1, 1, 10, 10, 0)- sqlite_session.add_all([app, conversation, message, account, user_feedback, admin_feedback])- sqlite_session.commit()- return {- "app": app,- "conversation": conversation,- "message": message,- "user_feedback": user_feedback,- "admin_feedback": admin_feedback,- }--- "sqlite_session",- [(App, Conversation, Message, MessageFeedback, Account)],- indirect=True,-)-class TestFeedbackService:- """Exercise feedback export formatting and its database-side filters."""-- def test_export_feedbacks_csv_format(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- result = FeedbackService.export_feedbacks(- app_id=APP_ID,- session=sqlite_session,- from_source=FeedbackFromSource.USER,- format_type="csv",- )-- assert "text/csv" in result.headers["Content-Type"]- assert "attachment" in result.headers["Content-Disposition"]- csv_content = result.get_data(as_text=True)- assert "feedback_id" in csv_content- assert "app_name" in csv_content- assert "conversation_id" in csv_content- assert sample_data["app"].name in csv_content- assert sample_data["message"].query in csv_content- assert sample_data["user_feedback"].content in csv_content- assert sample_data["admin_feedback"].content not in csv_content-- def test_export_feedbacks_json_format(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- result = FeedbackService.export_feedbacks(- app_id=APP_ID,- session=sqlite_session,- from_source=FeedbackFromSource.ADMIN,- format_type="json",- )-- assert "application/json" in result.headers["Content-Type"]- assert "attachment" in result.headers["Content-Disposition"]- json_content = json.loads(result.get_data(as_text=True))- assert json_content["export_info"]["app_id"] == APP_ID- assert json_content["export_info"]["total_records"] == 1- assert json_content["feedback_data"][0]["from_account_name"] == "Admin User"-- def test_export_feedbacks_with_filters(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- result = FeedbackService.export_feedbacks(- app_id=APP_ID,- session=sqlite_session,- from_source=FeedbackFromSource.ADMIN,- rating=FeedbackRating.DISLIKE,- has_comment=True,- start_date="2024-01-01",- end_date="2024-12-31",- format_type="csv",- )-- csv_content = result.get_data(as_text=True)- assert sample_data["admin_feedback"].content in csv_content- assert sample_data["user_feedback"].content not in csv_content- assert len([line for line in csv_content.strip().splitlines() if line.strip()]) == 2-- def test_export_feedbacks_no_data(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- result = FeedbackService.export_feedbacks(- app_id="77777777-7777-7777-7777-777777777777",- session=sqlite_session,- format_type="csv",- )-- csv_content = result.get_data(as_text=True)- assert "text/csv" in result.headers["Content-Type"]- assert "feedback_id" in csv_content- assert "app_name" in csv_content- assert "conversation_id" in csv_content- assert len([line for line in csv_content.strip().splitlines() if line.strip()]) == 1-- def test_export_feedbacks_invalid_date_format(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- with pytest.raises(ValueError, match="Invalid start_date format"):- FeedbackService.export_feedbacks(- app_id=APP_ID,- session=sqlite_session,- start_date="invalid-date-format",- )-- with pytest.raises(ValueError, match="Invalid end_date format"):- FeedbackService.export_feedbacks(- app_id=APP_ID,- session=sqlite_session,- end_date="invalid-date-format",- )-- def test_export_feedbacks_invalid_format(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- with pytest.raises(ValueError, match="Unsupported format"):- FeedbackService.export_feedbacks(app_id=APP_ID, session=sqlite_session, format_type="xml")-- def test_export_feedbacks_long_response_truncation(- self, sqlite_session: Session, sample_data: FeedbackSample- ) -> None:- sample_data["message"].answer = "A" * 600- sqlite_session.commit()-- result = FeedbackService.export_feedbacks(- app_id=APP_ID,- session=sqlite_session,- from_source=FeedbackFromSource.USER,- format_type="json",- )-- exported_answer = json.loads(result.get_data(as_text=True))["feedback_data"][0]["ai_response"]- assert exported_answer == "A" * 500 + "..."-- def test_export_feedbacks_unicode_content(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- sample_data["message"].query = "什么是人工智能?"- sample_data["message"].answer = "人工智能是模拟人类智能的技术。"- sample_data["user_feedback"].content = "回答不够详细,需要更多信息"- sqlite_session.commit()-- result = FeedbackService.export_feedbacks(- app_id=APP_ID,- session=sqlite_session,- from_source=FeedbackFromSource.USER,- format_type="csv",- )-- csv_content = result.get_data(as_text=True)- assert "什么是人工智能?" in csv_content- assert "回答不够详细,需要更多信息" in csv_content- assert "人工智能是模拟人类智能的技术" in csv_content-- def test_export_feedbacks_emoji_ratings(self, sqlite_session: Session, sample_data: FeedbackSample) -> None:- result = FeedbackService.export_feedbacks(app_id=APP_ID, session=sqlite_session, format_type="json")-- feedback_data = json.loads(result.get_data(as_text=True))["feedback_data"]- assert len(feedback_data) == 2- like_feedback = next(item for item in feedback_data if item["feedback_rating_raw"] == "like")- dislike_feedback = next(item for item in feedback_data if item["feedback_rating_raw"] == "dislike")- assert like_feedback["feedback_rating"] == "👍"- assert dislike_feedback["feedback_rating"] == "👎"---class TestEndDateBoundary:- """Verify that end_date includes feedback from the entire day (fix for #40050)."""-- def test_end_date_includes_entire_day(self):- from datetime import timedelta-- end_date = "2026-08-05"- end_dt = datetime.strptime(end_date, "%Y-%m-%d") + timedelta(days=1)-- assert end_dt == datetime(2026, 8, 6, 0, 0, 0)- assert datetime(2026, 8, 5, 14, 30, 0) < end_dt- assert datetime(2026, 8, 5, 23, 59, 59) < end_dt- assert not (datetime(2026, 8, 6, 0, 0, 1) < end_dt)-- def test_start_date_includes_midnight(self):- start_dt = datetime.strptime("2026-08-01", "%Y-%m-%d")- assert start_dt == datetime(2026, 8, 1, 0, 0, 0)- assert datetime(2026, 8, 1, 0, 0, 0) >= start_dtdiff --git a/packages/contracts/generated/api/console/apps/orpc.gen.ts b/packages/contracts/generated/api/console/apps/orpc.gen.tsindex 8df754ae8f6..2415c780024 100644--- a/packages/contracts/generated/api/console/apps/orpc.gen.ts+++ b/packages/contracts/generated/api/console/apps/orpc.gen.ts@@ -113,9 +113,6 @@ import {zGetAppsByAppIdExportPath,zGetAppsByAppIdExportQuery,zGetAppsByAppIdExportResponse,- zGetAppsByAppIdFeedbacksExportPath,- zGetAppsByAppIdFeedbacksExportQuery,- zGetAppsByAppIdFeedbacksExportResponse,zGetAppsByAppIdMessagesByMessageIdPath,zGetAppsByAppIdMessagesByMessageIdResponse,zGetAppsByAppIdPath,@@ -1820,30 +1817,6 @@ export const export2 = {get: get31,}-/**- * Export user feedback data for Google Sheets- */-export const get32 = oc- .route({- description: 'Export user feedback data for Google Sheets',- inputStructure: 'detailed',- method: 'GET',- operationId: 'getAppsByAppIdFeedbacksExport',- path: '/apps/{app_id}/feedbacks/export',- tags: ['console'],- })- .input(- z.object({- params: zGetAppsByAppIdFeedbacksExportPath,- query: zGetAppsByAppIdFeedbacksExportQuery.optional(),- }),- )- .output(zGetAppsByAppIdFeedbacksExportResponse)--export const export3 = {- get: get32,-}-/*** Create or update message feedback (like/dislike)*/@@ -1861,7 +1834,6 @@ export const post23 = ocexport const feedbacks = {post: post23,- export: export3,}/**@@ -1886,7 +1858,7 @@ export const icon = {/*** Get message details by ID*/-export const get33 = oc+export const get32 = oc.route({description: 'Get message details by ID',inputStructure: 'detailed',@@ -1899,7 +1871,7 @@ export const get33 = oc.output(zGetAppsByAppIdMessagesByMessageIdResponse)export const byMessageId2 = {- get: get33,+ get: get32,}export const messages = {@@ -1986,7 +1958,7 @@ export const refresh = {/*** Get MCP server configuration for an application*/-export const get34 = oc+export const get33 = oc.route({description: 'Get MCP server configuration for an application',inputStructure: 'detailed',@@ -2030,7 +2002,7 @@ export const put = oc.output(zPutAppsByAppIdServerResponse)export const server = {- get: get34,+ get: get33,post: post29,put,refresh,@@ -2132,7 +2104,7 @@ export const star = {/*** Get average response time statistics for an application*/-export const get35 = oc+export const get34 = oc.route({description: 'Get average response time statistics for an application',inputStructure: 'detailed',@@ -2150,13 +2122,13 @@ export const get35 = oc.output(zGetAppsByAppIdStatisticsAverageResponseTimeResponse)export const averageResponseTime = {- get: get35,+ get: get34,}/*** Get average session interaction statistics for an application*/-export const get36 = oc+export const get35 = oc.route({description: 'Get average session interaction statistics for an application',inputStructure: 'detailed',@@ -2174,13 +2146,13 @@ export const get36 = oc.output(zGetAppsByAppIdStatisticsAverageSessionInteractionsResponse)export const averageSessionInteractions = {- get: get36,+ get: get35,}/*** Get daily conversation statistics for an application*/-export const get37 = oc+export const get36 = oc.route({description: 'Get daily conversation statistics for an application',inputStructure: 'detailed',@@ -2198,13 +2170,13 @@ export const get37 = oc.output(zGetAppsByAppIdStatisticsDailyConversationsResponse)export const dailyConversations = {- get: get37,+ get: get36,}/*** Get daily terminal/end-user statistics for an application*/-export const get38 = oc+export const get37 = oc.route({description: 'Get daily terminal/end-user statistics for an application',inputStructure: 'detailed',@@ -2222,13 +2194,13 @@ export const get38 = oc.output(zGetAppsByAppIdStatisticsDailyEndUsersResponse)export const dailyEndUsers = {- get: get38,+ get: get37,}/*** Get daily message statistics for an application*/-export const get39 = oc+export const get38 = oc.route({description: 'Get daily message statistics for an application',inputStructure: 'detailed',@@ -2246,13 +2218,13 @@ export const get39 = oc.output(zGetAppsByAppIdStatisticsDailyMessagesResponse)export const dailyMessages = {- get: get39,+ get: get38,}/*** Get daily token cost statistics for an application*/-export const get40 = oc+export const get39 = oc.route({description: 'Get daily token cost statistics for an application',inputStructure: 'detailed',@@ -2270,13 +2242,13 @@ export const get40 = oc.output(zGetAppsByAppIdStatisticsTokenCostsResponse)export const tokenCosts = {- get: get40,+ get: get39,}/*** Get tokens per second statistics for an application*/-export const get41 = oc+export const get40 = oc.route({description: 'Get tokens per second statistics for an application',inputStructure: 'detailed',@@ -2294,13 +2266,13 @@ export const get41 = oc.output(zGetAppsByAppIdStatisticsTokensPerSecondResponse)export const tokensPerSecond = {- get: get41,+ get: get40,}/*** Get user satisfaction rate statistics for an application*/-export const get42 = oc+export const get41 = oc.route({description: 'Get user satisfaction rate statistics for an application',inputStructure: 'detailed',@@ -2318,7 +2290,7 @@ export const get42 = oc.output(zGetAppsByAppIdStatisticsUserSatisfactionRateResponse)export const userSatisfactionRate = {- get: get42,+ get: get41,}export const statistics = {@@ -2335,7 +2307,7 @@ export const statistics = {/*** Get available TTS voices for a specific language*/-export const get43 = oc+export const get42 = oc.route({description: 'Get available TTS voices for a specific language',inputStructure: 'detailed',@@ -2353,7 +2325,7 @@ export const get43 = oc.output(zGetAppsByAppIdTextToAudioVoicesResponse)export const voices = {- get: get43,+ get: get42,}/**@@ -2381,7 +2353,7 @@ export const textToAudio = {/*** Get app tracing configuration*/-export const get44 = oc+export const get43 = oc.route({description: 'Get app tracing configuration',inputStructure: 'detailed',@@ -2409,7 +2381,7 @@ export const post35 = oc.output(zPostAppsByAppIdTraceResponse)export const trace = {- get: get44,+ get: get43,post: post35,}@@ -2440,7 +2412,7 @@ export const delete8 = oc/*** Get tracing configuration for an application*/-export const get45 = oc+export const get44 = oc.route({description: 'Get tracing configuration for an application',inputStructure: 'detailed',@@ -2497,7 +2469,7 @@ export const post36 = ocexport const traceConfig = {delete: delete8,- get: get45,+ get: get44,patch,post: post36,}@@ -2529,7 +2501,7 @@ export const triggerEnable = {/*** Get app triggers list*/-export const get46 = oc+export const get45 = oc.route({inputStructure: 'detailed',method: 'GET',@@ -2542,7 +2514,7 @@ export const get46 = oc.output(zGetAppsByAppIdTriggersResponse)export const triggers = {- get: get46,+ get: get45,}/**@@ -2550,7 +2522,7 @@ export const triggers = {** Get workflow application execution logs*/-export const get47 = oc+export const get46 = oc.route({description: 'Get workflow application execution logs',inputStructure: 'detailed',@@ -2569,7 +2541,7 @@ export const get47 = oc.output(zGetAppsByAppIdWorkflowAppLogsResponse)export const workflowAppLogs = {- get: get47,+ get: get46,}/**@@ -2577,7 +2549,7 @@ export const workflowAppLogs = {** Get workflow runs count statistics*/-export const get48 = oc+export const get47 = oc.route({description: 'Get workflow runs count statistics',inputStructure: 'detailed',@@ -2596,7 +2568,7 @@ export const get48 = oc.output(zGetAppsByAppIdWorkflowRunsCountResponse)export const count3 = {- get: get48,+ get: get47,}/**@@ -2634,7 +2606,7 @@ export const tasks = {** Get workflow run node execution list*/-export const get49 = oc+export const get48 = oc.route({description: 'Get workflow run node execution list',inputStructure: 'detailed',@@ -2648,7 +2620,7 @@ export const get49 = oc.output(zGetAppsByAppIdWorkflowRunsByRunIdNodeExecutionsResponse)export const nodeExecutions = {- get: get49,+ get: get48,}/**@@ -2656,7 +2628,7 @@ export const nodeExecutions = {** Get workflow run detail*/-export const get50 = oc+export const get49 = oc.route({description: 'Get workflow run detail',inputStructure: 'detailed',@@ -2670,7 +2642,7 @@ export const get50 = oc.output(zGetAppsByAppIdWorkflowRunsByRunIdResponse)export const byRunId = {- get: get50,+ get: get49,nodeExecutions,}@@ -2702,7 +2674,7 @@ export const download4 = {/*** Read a text/binary preview file in a workflow Agent node sandbox*/-export const get51 = oc+export const get50 = oc.route({description: 'Read a text/binary preview file in a workflow Agent node sandbox',inputStructure: 'detailed',@@ -2720,13 +2692,13 @@ export const get51 = oc.output(zGetAppsByAppIdWorkflowRunsByWorkflowRunIdAgentNodesByNodeIdSandboxFilesReadResponse)export const read = {- get: get51,+ get: get50,}/*** List a directory in a workflow Agent node sandbox*/-export const get52 = oc+export const get51 = oc.route({description: 'List a directory in a workflow Agent node sandbox',inputStructure: 'detailed',@@ -2744,7 +2716,7 @@ export const get52 = oc.output(zGetAppsByAppIdWorkflowRunsByWorkflowRunIdAgentNodesByNodeIdSandboxFilesResponse)export const files3 = {- get: get52,+ get: get51,download: download4,read,}@@ -2770,7 +2742,7 @@ export const byWorkflowRunId = {** Get workflow run list*/-export const get53 = oc+export const get52 = oc.route({description: 'Get workflow run list',inputStructure: 'detailed',@@ -2789,7 +2761,7 @@ export const get53 = oc.output(zGetAppsByAppIdWorkflowRunsResponse)export const workflowRuns2 = {- get: get53,+ get: get52,count: count3,tasks,byRunId,@@ -2801,7 +2773,7 @@ export const workflowRuns2 = {** Get all users in current tenant for mentions*/-export const get54 = oc+export const get53 = oc.route({description: 'Get all users in current tenant for mentions',inputStructure: 'detailed',@@ -2815,7 +2787,7 @@ export const get54 = oc.output(zGetAppsByAppIdWorkflowCommentsMentionUsersResponse)export const mentionUsers = {- get: get54,+ get: get53,}/**@@ -2940,7 +2912,7 @@ export const delete10 = oc** Get a specific workflow comment*/-export const get55 = oc+export const get54 = oc.route({description: 'Get a specific workflow comment',inputStructure: 'detailed',@@ -2978,7 +2950,7 @@ export const put3 = ocexport const byCommentId = {delete: delete10,- get: get55,+ get: get54,put: put3,replies,resolve,@@ -2989,7 +2961,7 @@ export const byCommentId = {** Get all comments for a workflow*/-export const get56 = oc+export const get55 = oc.route({description: 'Get all comments for a workflow',inputStructure: 'detailed',@@ -3027,7 +2999,7 @@ export const post42 = oc.output(zPostAppsByAppIdWorkflowCommentsResponse)export const comments = {- get: get56,+ get: get55,post: post42,mentionUsers,byCommentId,@@ -3036,7 +3008,7 @@ export const comments = {/*** Get workflow average app interaction statistics*/-export const get57 = oc+export const get56 = oc.route({description: 'Get workflow average app interaction statistics',inputStructure: 'detailed',@@ -3054,13 +3026,13 @@ export const get57 = oc.output(zGetAppsByAppIdWorkflowStatisticsAverageAppInteractionsResponse)export const averageAppInteractions = {- get: get57,+ get: get56,}/*** Get workflow daily runs statistics*/-export const get58 = oc+export const get57 = oc.route({description: 'Get workflow daily runs statistics',inputStructure: 'detailed',@@ -3078,13 +3050,13 @@ export const get58 = oc.output(zGetAppsByAppIdWorkflowStatisticsDailyConversationsResponse)export const dailyConversations2 = {- get: get58,+ get: get57,}/*** Get workflow daily terminals statistics*/-export const get59 = oc+export const get58 = oc.route({description: 'Get workflow daily terminals statistics',inputStructure: 'detailed',@@ -3102,13 +3074,13 @@ export const get59 = oc.output(zGetAppsByAppIdWorkflowStatisticsDailyTerminalsResponse)export const dailyTerminals = {- get: get59,+ get: get58,}/*** Get workflow daily token cost statistics*/-export const get60 = oc+export const get59 = oc.route({description: 'Get workflow daily token cost statistics',inputStructure: 'detailed',@@ -3126,7 +3098,7 @@ export const get60 = oc.output(zGetAppsByAppIdWorkflowStatisticsTokenCostsResponse)export const tokenCosts2 = {- get: get60,+ get: get59,}export const statistics2 = {@@ -3146,7 +3118,7 @@ export const workflow = {** Get default block configuration by type*/-export const get61 = oc+export const get60 = oc.route({description: 'Get default block configuration by type',inputStructure: 'detailed',@@ -3165,7 +3137,7 @@ export const get61 = oc.output(zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsByBlockTypeResponse)export const byBlockType = {- get: get61,+ get: get60,}/**@@ -3173,7 +3145,7 @@ export const byBlockType = {** Get default block configurations for workflow*/-export const get62 = oc+export const get61 = oc.route({description: 'Get default block configurations for workflow',inputStructure: 'detailed',@@ -3187,14 +3159,14 @@ export const get62 = oc.output(zGetAppsByAppIdWorkflowsDefaultWorkflowBlockConfigsResponse)export const defaultWorkflowBlockConfigs = {- get: get62,+ get: get61,byBlockType,}/*** Get conversation variables for workflow*/-export const get63 = oc+export const get62 = oc.route({description: 'Get conversation variables for workflow',inputStructure: 'detailed',@@ -3227,7 +3199,7 @@ export const post43 = oc.output(zPostAppsByAppIdWorkflowsDraftConversationVariablesResponse)export const conversationVariables2 = {- get: get63,+ get: get62,post: post43,}@@ -3236,7 +3208,7 @@ export const conversationVariables2 = {** Get environment variables for workflow*/-export const get64 = oc+export const get63 = oc.route({description: 'Get environment variables for workflow',inputStructure: 'detailed',@@ -3270,7 +3242,7 @@ export const post44 = oc.output(zPostAppsByAppIdWorkflowsDraftEnvironmentVariablesResponse)export const environmentVariables = {- get: get64,+ get: get63,post: post44,}@@ -3475,7 +3447,7 @@ export const loop2 = {nodes: nodes6,}-export const get65 = oc+export const get64 = oc.route({inputStructure: 'detailed',method: 'GET',@@ -3489,7 +3461,7 @@ export const get65 = oc.output(zGetAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerCandidatesResponse)export const candidates = {- get: get65,+ get: get64,}export const post51 = oc@@ -3572,7 +3544,7 @@ export const validate = {post: post54,}-export const get66 = oc+export const get65 = oc.route({inputStructure: 'detailed',method: 'GET',@@ -3605,7 +3577,7 @@ export const put4 = oc.output(zPutAppsByAppIdWorkflowsDraftNodesByNodeIdAgentComposerResponse)export const agentComposer = {- get: get66,+ get: get65,put: put4,candidates,copyFromRoster,@@ -3617,7 +3589,7 @@ export const agentComposer = {/*** Get last run result for draft workflow node*/-export const get67 = oc+export const get66 = oc.route({description: 'Get last run result for draft workflow node',inputStructure: 'detailed',@@ -3630,7 +3602,7 @@ export const get67 = oc.output(zGetAppsByAppIdWorkflowsDraftNodesByNodeIdLastRunResponse)export const lastRun = {- get: get67,+ get: get66,}/**@@ -3705,7 +3677,7 @@ export const delete11 = oc/*** Get variables for a specific node*/-export const get68 = oc+export const get67 = oc.route({description: 'Get variables for a specific node',inputStructure: 'detailed',@@ -3719,7 +3691,7 @@ export const get68 = ocexport const variables = {delete: delete11,- get: get68,+ get: get67,}export const byNodeId8 = {@@ -3764,7 +3736,7 @@ export const run10 = {/*** Server-Sent Events stream of inspector deltas for a draft workflow run.*/-export const get69 = oc+export const get68 = oc.route({description: 'Server-Sent Events stream of inspector deltas for a draft workflow run.',inputStructure: 'detailed',@@ -3777,13 +3749,13 @@ export const get69 = oc.output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsEventsResponse)export const events = {- get: get69,+ get: get68,}/*** Full value for one declared output, including signed download URL for files.*/-export const get70 = oc+export const get69 = oc.route({description: 'Full value for one declared output, including signed download URL for files.',inputStructure: 'detailed',@@ -3800,7 +3772,7 @@ export const get70 = oc.output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsByNodeIdByOutputNamePreviewResponse)export const preview5 = {- get: get70,+ get: get69,}export const byOutputName = {@@ -3810,7 +3782,7 @@ export const byOutputName = {/*** One node's declared outputs for a draft workflow run.*/-export const get71 = oc+export const get70 = oc.route({description: "One node's declared outputs for a draft workflow run.",inputStructure: 'detailed',@@ -3823,14 +3795,14 @@ export const get71 = oc.output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsByNodeIdResponse)export const byNodeId9 = {- get: get71,+ get: get70,byOutputName,}/*** Snapshot of every node's declared outputs for a draft workflow run.*/-export const get72 = oc+export const get71 = oc.route({description: "Snapshot of every node's declared outputs for a draft workflow run.",inputStructure: 'detailed',@@ -3843,7 +3815,7 @@ export const get72 = oc.output(zGetAppsByAppIdWorkflowsDraftRunsByRunIdNodeOutputsResponse)export const nodeOutputs = {- get: get72,+ get: get71,events,byNodeId: byNodeId9,}@@ -3859,7 +3831,7 @@ export const runs = {/*** Get system variables for workflow*/-export const get73 = oc+export const get72 = oc.route({description: 'Get system variables for workflow',inputStructure: 'detailed',@@ -3872,7 +3844,7 @@ export const get73 = oc.output(zGetAppsByAppIdWorkflowsDraftSystemVariablesResponse)export const systemVariables = {- get: get73,+ get: get72,}/**@@ -3972,7 +3944,7 @@ export const delete12 = oc/*** Get a specific workflow variable*/-export const get74 = oc+export const get73 = oc.route({description: 'Get a specific workflow variable',inputStructure: 'detailed',@@ -4006,7 +3978,7 @@ export const patch2 = ocexport const byVariableId = {delete: delete12,- get: get74,+ get: get73,patch: patch2,reset,}@@ -4032,7 +4004,7 @@ export const delete13 = oc** Get draft workflow variables*/-export const get75 = oc+export const get74 = oc.route({description: 'Get draft workflow variables',inputStructure: 'detailed',@@ -4052,7 +4024,7 @@ export const get75 = ocexport const variables2 = {delete: delete13,- get: get75,+ get: get74,byVariableId,}@@ -4061,7 +4033,7 @@ export const variables2 = {** Get draft workflow for an application*/-export const get76 = oc+export const get75 = oc.route({description: 'Get draft workflow for an application',inputStructure: 'detailed',@@ -4098,7 +4070,7 @@ export const post60 = oc.output(zPostAppsByAppIdWorkflowsDraftResponse)export const draft2 = {- get: get76,+ get: get75,post: post60,conversationVariables: conversationVariables2,environmentVariables,@@ -4119,7 +4091,7 @@ export const draft2 = {** Get published workflow for an application*/-export const get77 = oc+export const get76 = oc.route({description: 'Get published workflow for an application',inputStructure: 'detailed',@@ -4153,14 +4125,14 @@ export const post61 = oc.output(zPostAppsByAppIdWorkflowsPublishResponse)export const publish = {- get: get77,+ get: get76,post: post61,}/*** Server-Sent Events stream of inspector deltas for a published workflow run.*/-export const get78 = oc+export const get77 = oc.route({description: 'Server-Sent Events stream of inspector deltas for a published workflow run.',inputStructure: 'detailed',@@ -4173,13 +4145,13 @@ export const get78 = oc.output(zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsEventsResponse)export const events2 = {- get: get78,+ get: get77,}/*** Full value for one declared output of a published run.*/-export const get79 = oc+export const get78 = oc.route({description: 'Full value for one declared output of a published run.',inputStructure: 'detailed',@@ -4200,7 +4172,7 @@ export const get79 = oc)export const preview6 = {- get: get79,+ get: get78,}export const byOutputName2 = {@@ -4210,7 +4182,7 @@ export const byOutputName2 = {/*** One node's declared outputs for a published workflow run.*/-export const get80 = oc+export const get79 = oc.route({description: "One node's declared outputs for a published workflow run.",inputStructure: 'detailed',@@ -4223,14 +4195,14 @@ export const get80 = oc.output(zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsByNodeIdResponse)export const byNodeId10 = {- get: get80,+ get: get79,byOutputName: byOutputName2,}/*** Snapshot of every node's declared outputs for a published workflow run.*/-export const get81 = oc+export const get80 = oc.route({description: "Snapshot of every node's declared outputs for a published workflow run.",inputStructure: 'detailed',@@ -4243,7 +4215,7 @@ export const get81 = oc.output(zGetAppsByAppIdWorkflowsPublishedRunsByRunIdNodeOutputsResponse)export const nodeOutputs2 = {- get: get81,+ get: get80,events: events2,byNodeId: byNodeId10,}@@ -4263,7 +4235,7 @@ export const published = {/*** Get webhook trigger for a node*/-export const get82 = oc+export const get81 = oc.route({inputStructure: 'detailed',method: 'GET',@@ -4281,7 +4253,7 @@ export const get82 = oc.output(zGetAppsByAppIdWorkflowsTriggersWebhookResponse)export const webhook = {- get: get82,+ get: get81,}export const triggers2 = {@@ -4356,7 +4328,7 @@ export const byWorkflowId = {** Get all published workflows for an application*/-export const get83 = oc+export const get82 = oc.route({description: 'Get all published workflows for an application',inputStructure: 'detailed',@@ -4375,7 +4347,7 @@ export const get83 = oc.output(zGetAppsByAppIdWorkflowsResponse)export const workflows3 = {- get: get83,+ get: get82,defaultWorkflowBlockConfigs,draft: draft2,publish,@@ -4403,7 +4375,7 @@ export const delete15 = oc/*** Get application details*/-export const get84 = oc+export const get83 = oc.route({description: 'Get application details',inputStructure: 'detailed',@@ -4432,7 +4404,7 @@ export const put6 = ocexport const byAppId2 = {delete: delete15,- get: get84,+ get: get83,put: put6,advancedChat,agent,@@ -4495,7 +4467,7 @@ export const byApiKeyId = {/*** Get all API keys for an app*/-export const get85 = oc+export const get84 = oc.route({description: 'Get all API keys for an app',inputStructure: 'detailed',@@ -4524,7 +4496,7 @@ export const post63 = oc.output(zPostAppsByResourceIdApiKeysResponse)export const apiKeys = {- get: get85,+ get: get84,post: post63,byApiKeyId,}@@ -4536,7 +4508,7 @@ export const byResourceId = {/*** Get list of applications with pagination and filtering*/-export const get86 = oc+export const get85 = oc.route({description: 'Get list of applications with pagination and filtering',inputStructure: 'detailed',@@ -4565,7 +4537,7 @@ export const post64 = oc.output(zPostAppsResponse)export const apps = {- get: get86,+ get: get85,post: post64,imports,recent,diff --git a/packages/contracts/generated/api/console/apps/types.gen.ts b/packages/contracts/generated/api/console/apps/types.gen.tsindex 5fe09deb28b..699e360be19 100644--- a/packages/contracts/generated/api/console/apps/types.gen.ts+++ b/packages/contracts/generated/api/console/apps/types.gen.ts@@ -503,8 +503,6 @@ export type MessageFeedbackPayload = {rating?: 'dislike' | 'like' | null}-export type TextFileResponse = string-export type AppIconPayload = {icon?: string | nullicon_background?: string | null@@ -5548,34 +5546,6 @@ export type PostAppsByAppIdFeedbacksResponses = {export type PostAppsByAppIdFeedbacksResponse =PostAppsByAppIdFeedbacksResponses[keyof PostAppsByAppIdFeedbacksResponses]-export type GetAppsByAppIdFeedbacksExportData = {- body?: never- path: {- app_id: string- }- query?: {- end_date?: string- format?: 'csv' | 'json'- from_source?: 'admin' | 'user'- has_comment?: boolean- rating?: 'dislike' | 'like'- start_date?: string- }- url: '/apps/{app_id}/feedbacks/export'-}--export type GetAppsByAppIdFeedbacksExportErrors = {- 400: unknown- 500: unknown-}--export type GetAppsByAppIdFeedbacksExportResponses = {- 200: TextFileResponse-}--export type GetAppsByAppIdFeedbacksExportResponse =- GetAppsByAppIdFeedbacksExportResponses[keyof GetAppsByAppIdFeedbacksExportResponses]-export type PostAppsByAppIdIconData = {body: AppIconPayloadpath: {diff --git a/packages/contracts/generated/api/console/apps/zod.gen.ts b/packages/contracts/generated/api/console/apps/zod.gen.tsindex 3c54f3e3313..d8ab6cd9316 100644--- a/packages/contracts/generated/api/console/apps/zod.gen.ts+++ b/packages/contracts/generated/api/console/apps/zod.gen.ts@@ -319,11 +319,6 @@ export const zMessageFeedbackPayload = z.object({rating: z.enum(['dislike', 'like']).nullish(),})-/**- * TextFileResponse- */-export const zTextFileResponse = z.string()-/*** AppNamePayload*/@@ -6237,24 +6232,6 @@ export const zPostAppsByAppIdFeedbacksPath = z.object({*/export const zPostAppsByAppIdFeedbacksResponse = zSimpleResultResponse-export const zGetAppsByAppIdFeedbacksExportPath = z.object({- app_id: z.uuid(),-})--export const zGetAppsByAppIdFeedbacksExportQuery = z.object({- end_date: z.string().optional(),- format: z.enum(['csv', 'json']).optional().default('csv'),- from_source: z.enum(['admin', 'user']).optional(),- has_comment: z.boolean().optional(),- rating: z.enum(['dislike', 'like']).optional(),- start_date: z.string().optional(),-})--/**- * Feedback data exported successfully- */-export const zGetAppsByAppIdFeedbacksExportResponse = zTextFileResponse-export const zPostAppsByAppIdIconBody = zAppIconPayloadexport const zPostAppsByAppIdIconPath = z.object({diff --git a/packages/contracts/non-json-openapi-responses.md b/packages/contracts/non-json-openapi-responses.mdindex 9cb6b35cb4a..ce3e0f6ee78 100644--- a/packages/contracts/non-json-openapi-responses.md+++ b/packages/contracts/non-json-openapi-responses.md@@ -25,10 +25,9 @@ The current Flask-RESTX generator still emits these response entries under `appl## Text File Exports-| Spec | Method | Path | Runtime response | Schema |-| ------- | ------ | ------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------ |-| console | GET | `/apps/{app_id}/feedbacks/export` | `text/csv` attachment by default; `format=json` returns JSON attachment | `TextFileResponse` |-| console | GET | `/workspaces/current/customized-snippets/{snippet_id}/export` | `application/x-yaml` attachment | `TextFileResponse` |+| Spec | Method | Path | Runtime response | Schema |+| ------- | ------ | ------------------------------------------------------------- | ------------------------------- | ------------------ |+| console | GET | `/workspaces/current/customized-snippets/{snippet_id}/export` | `application/x-yaml` attachment | `TextFileResponse` |## Fixed SSE Streams