Co-authored-by: Yongtao Huang <99629139+hyongtao-db@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>tags/1.8.0
| @@ -1,5 +1,7 @@ | |||
| from werkzeug.exceptions import HTTPException | |||
| from libs.exception import BaseHTTPException | |||
| class FilenameNotExistsError(HTTPException): | |||
| code = 400 | |||
| @@ -9,3 +11,27 @@ class FilenameNotExistsError(HTTPException): | |||
| class RemoteFileUploadError(HTTPException): | |||
| code = 400 | |||
| description = "Error uploading remote file." | |||
| class FileTooLargeError(BaseHTTPException): | |||
| error_code = "file_too_large" | |||
| description = "File size exceeded. {message}" | |||
| code = 413 | |||
| class UnsupportedFileTypeError(BaseHTTPException): | |||
| error_code = "unsupported_file_type" | |||
| description = "File type not allowed." | |||
| code = 415 | |||
| class TooManyFilesError(BaseHTTPException): | |||
| error_code = "too_many_files" | |||
| description = "Only one file is allowed." | |||
| code = 400 | |||
| class NoFileUploadedError(BaseHTTPException): | |||
| error_code = "no_file_uploaded" | |||
| description = "Please upload your file." | |||
| code = 400 | |||
| @@ -3,9 +3,8 @@ from flask_login import current_user | |||
| from flask_restful import Resource, marshal, marshal_with, reqparse | |||
| from werkzeug.exceptions import Forbidden | |||
| from controllers.common.errors import NoFileUploadedError, TooManyFilesError | |||
| from controllers.console import api | |||
| from controllers.console.app.error import NoFileUploadedError | |||
| from controllers.console.datasets.error import TooManyFilesError | |||
| from controllers.console.wraps import ( | |||
| account_initialization_required, | |||
| cloud_edition_billing_resource_check, | |||
| @@ -79,18 +79,6 @@ class ProviderNotSupportSpeechToTextError(BaseHTTPException): | |||
| code = 400 | |||
| class NoFileUploadedError(BaseHTTPException): | |||
| error_code = "no_file_uploaded" | |||
| description = "Please upload your file." | |||
| code = 400 | |||
| class TooManyFilesError(BaseHTTPException): | |||
| error_code = "too_many_files" | |||
| description = "Only one file is allowed." | |||
| code = 400 | |||
| class DraftWorkflowNotExist(BaseHTTPException): | |||
| error_code = "draft_workflow_not_exist" | |||
| description = "Draft workflow need to be initialized." | |||
| @@ -1,30 +1,6 @@ | |||
| from libs.exception import BaseHTTPException | |||
| class NoFileUploadedError(BaseHTTPException): | |||
| error_code = "no_file_uploaded" | |||
| description = "Please upload your file." | |||
| code = 400 | |||
| class TooManyFilesError(BaseHTTPException): | |||
| error_code = "too_many_files" | |||
| description = "Only one file is allowed." | |||
| code = 400 | |||
| class FileTooLargeError(BaseHTTPException): | |||
| error_code = "file_too_large" | |||
| description = "File size exceeded. {message}" | |||
| code = 413 | |||
| class UnsupportedFileTypeError(BaseHTTPException): | |||
| error_code = "unsupported_file_type" | |||
| description = "File type not allowed." | |||
| code = 415 | |||
| class DatasetNotInitializedError(BaseHTTPException): | |||
| error_code = "dataset_not_initialized" | |||
| description = "The dataset is still being initialized or indexing. Please wait a moment." | |||
| @@ -76,30 +76,6 @@ class EmailSendIpLimitError(BaseHTTPException): | |||
| code = 429 | |||
| class FileTooLargeError(BaseHTTPException): | |||
| error_code = "file_too_large" | |||
| description = "File size exceeded. {message}" | |||
| code = 413 | |||
| class UnsupportedFileTypeError(BaseHTTPException): | |||
| error_code = "unsupported_file_type" | |||
| description = "File type not allowed." | |||
| code = 415 | |||
| class TooManyFilesError(BaseHTTPException): | |||
| error_code = "too_many_files" | |||
| description = "Only one file is allowed." | |||
| code = 400 | |||
| class NoFileUploadedError(BaseHTTPException): | |||
| error_code = "no_file_uploaded" | |||
| description = "Please upload your file." | |||
| code = 400 | |||
| class UnauthorizedAndForceLogout(BaseHTTPException): | |||
| error_code = "unauthorized_and_force_logout" | |||
| description = "Unauthorized and force logout." | |||
| @@ -8,7 +8,13 @@ from werkzeug.exceptions import Forbidden | |||
| import services | |||
| from configs import dify_config | |||
| from constants import DOCUMENT_EXTENSIONS | |||
| from controllers.common.errors import FilenameNotExistsError | |||
| from controllers.common.errors import ( | |||
| FilenameNotExistsError, | |||
| FileTooLargeError, | |||
| NoFileUploadedError, | |||
| TooManyFilesError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from controllers.console.wraps import ( | |||
| account_initialization_required, | |||
| cloud_edition_billing_resource_check, | |||
| @@ -18,13 +24,6 @@ from fields.file_fields import file_fields, upload_config_fields | |||
| from libs.login import login_required | |||
| from services.file_service import FileService | |||
| from .error import ( | |||
| FileTooLargeError, | |||
| NoFileUploadedError, | |||
| TooManyFilesError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| PREVIEW_WORDS_LIMIT = 3000 | |||
| @@ -7,18 +7,17 @@ from flask_restful import Resource, marshal_with, reqparse | |||
| import services | |||
| from controllers.common import helpers | |||
| from controllers.common.errors import RemoteFileUploadError | |||
| from controllers.common.errors import ( | |||
| FileTooLargeError, | |||
| RemoteFileUploadError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from core.file import helpers as file_helpers | |||
| from core.helper import ssrf_proxy | |||
| from fields.file_fields import file_fields_with_signed_url, remote_file_info_fields | |||
| from models.account import Account | |||
| from services.file_service import FileService | |||
| from .error import ( | |||
| FileTooLargeError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| class RemoteFileInfoApi(Resource): | |||
| @marshal_with(remote_file_info_fields) | |||
| @@ -7,15 +7,15 @@ from sqlalchemy import select | |||
| from werkzeug.exceptions import Unauthorized | |||
| import services | |||
| from controllers.common.errors import FilenameNotExistsError | |||
| from controllers.console import api | |||
| from controllers.console.admin import admin_required | |||
| from controllers.console.datasets.error import ( | |||
| from controllers.common.errors import ( | |||
| FilenameNotExistsError, | |||
| FileTooLargeError, | |||
| NoFileUploadedError, | |||
| TooManyFilesError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from controllers.console import api | |||
| from controllers.console.admin import admin_required | |||
| from controllers.console.error import AccountNotLinkTenantError | |||
| from controllers.console.wraps import ( | |||
| account_initialization_required, | |||
| @@ -1,7 +0,0 @@ | |||
| from libs.exception import BaseHTTPException | |||
| class UnsupportedFileTypeError(BaseHTTPException): | |||
| error_code = "unsupported_file_type" | |||
| description = "File type not allowed." | |||
| code = 415 | |||
| @@ -5,8 +5,8 @@ from flask_restful import Resource, reqparse | |||
| from werkzeug.exceptions import NotFound | |||
| import services | |||
| from controllers.common.errors import UnsupportedFileTypeError | |||
| from controllers.files import api | |||
| from controllers.files.error import UnsupportedFileTypeError | |||
| from services.account_service import TenantService | |||
| from services.file_service import FileService | |||
| @@ -4,8 +4,8 @@ from flask import Response | |||
| from flask_restful import Resource, reqparse | |||
| from werkzeug.exceptions import Forbidden, NotFound | |||
| from controllers.common.errors import UnsupportedFileTypeError | |||
| from controllers.files import api | |||
| from controllers.files.error import UnsupportedFileTypeError | |||
| from core.tools.signature import verify_tool_file_signature | |||
| from core.tools.tool_file_manager import ToolFileManager | |||
| from models import db as global_db | |||
| @@ -5,11 +5,13 @@ from flask_restful import Resource, marshal_with | |||
| from werkzeug.exceptions import Forbidden | |||
| import services | |||
| from controllers.common.errors import ( | |||
| FileTooLargeError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from controllers.console.wraps import setup_required | |||
| from controllers.files import api | |||
| from controllers.files.error import UnsupportedFileTypeError | |||
| from controllers.inner_api.plugin.wraps import get_user | |||
| from controllers.service_api.app.error import FileTooLargeError | |||
| from core.file.helpers import verify_plugin_file_signature | |||
| from core.tools.tool_file_manager import ToolFileManager | |||
| from fields.file_fields import file_fields | |||
| @@ -85,30 +85,6 @@ class ProviderNotSupportSpeechToTextError(BaseHTTPException): | |||
| code = 400 | |||
| class NoFileUploadedError(BaseHTTPException): | |||
| error_code = "no_file_uploaded" | |||
| description = "Please upload your file." | |||
| code = 400 | |||
| class TooManyFilesError(BaseHTTPException): | |||
| error_code = "too_many_files" | |||
| description = "Only one file is allowed." | |||
| code = 400 | |||
| class FileTooLargeError(BaseHTTPException): | |||
| error_code = "file_too_large" | |||
| description = "File size exceeded. {message}" | |||
| code = 413 | |||
| class UnsupportedFileTypeError(BaseHTTPException): | |||
| error_code = "unsupported_file_type" | |||
| description = "File type not allowed." | |||
| code = 415 | |||
| class FileNotFoundError(BaseHTTPException): | |||
| error_code = "file_not_found" | |||
| description = "The requested file was not found." | |||
| @@ -2,14 +2,14 @@ from flask import request | |||
| from flask_restful import Resource, marshal_with | |||
| import services | |||
| from controllers.common.errors import FilenameNotExistsError | |||
| from controllers.service_api import api | |||
| from controllers.service_api.app.error import ( | |||
| from controllers.common.errors import ( | |||
| FilenameNotExistsError, | |||
| FileTooLargeError, | |||
| NoFileUploadedError, | |||
| TooManyFilesError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from controllers.service_api import api | |||
| from controllers.service_api.wraps import FetchUserArg, WhereisUserArg, validate_app_token | |||
| from fields.file_fields import file_fields | |||
| from models.model import App, EndUser | |||
| @@ -6,15 +6,15 @@ from sqlalchemy import desc, select | |||
| from werkzeug.exceptions import Forbidden, NotFound | |||
| import services | |||
| from controllers.common.errors import FilenameNotExistsError | |||
| from controllers.service_api import api | |||
| from controllers.service_api.app.error import ( | |||
| from controllers.common.errors import ( | |||
| FilenameNotExistsError, | |||
| FileTooLargeError, | |||
| NoFileUploadedError, | |||
| ProviderNotInitializeError, | |||
| TooManyFilesError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from controllers.service_api import api | |||
| from controllers.service_api.app.error import ProviderNotInitializeError | |||
| from controllers.service_api.dataset.error import ( | |||
| ArchivedDocumentImmutableError, | |||
| DocumentIndexingError, | |||
| @@ -1,30 +1,6 @@ | |||
| from libs.exception import BaseHTTPException | |||
| class NoFileUploadedError(BaseHTTPException): | |||
| error_code = "no_file_uploaded" | |||
| description = "Please upload your file." | |||
| code = 400 | |||
| class TooManyFilesError(BaseHTTPException): | |||
| error_code = "too_many_files" | |||
| description = "Only one file is allowed." | |||
| code = 400 | |||
| class FileTooLargeError(BaseHTTPException): | |||
| error_code = "file_too_large" | |||
| description = "File size exceeded. {message}" | |||
| code = 413 | |||
| class UnsupportedFileTypeError(BaseHTTPException): | |||
| error_code = "unsupported_file_type" | |||
| description = "File type not allowed." | |||
| code = 415 | |||
| class DatasetNotInitializedError(BaseHTTPException): | |||
| error_code = "dataset_not_initialized" | |||
| description = "The dataset is still being initialized or indexing. Please wait a moment." | |||
| @@ -97,30 +97,6 @@ class ProviderNotSupportSpeechToTextError(BaseHTTPException): | |||
| code = 400 | |||
| class NoFileUploadedError(BaseHTTPException): | |||
| error_code = "no_file_uploaded" | |||
| description = "Please upload your file." | |||
| code = 400 | |||
| class TooManyFilesError(BaseHTTPException): | |||
| error_code = "too_many_files" | |||
| description = "Only one file is allowed." | |||
| code = 400 | |||
| class FileTooLargeError(BaseHTTPException): | |||
| error_code = "file_too_large" | |||
| description = "File size exceeded. {message}" | |||
| code = 413 | |||
| class UnsupportedFileTypeError(BaseHTTPException): | |||
| error_code = "unsupported_file_type" | |||
| description = "File type not allowed." | |||
| code = 415 | |||
| class WebAppAuthRequiredError(BaseHTTPException): | |||
| error_code = "web_sso_auth_required" | |||
| description = "Web app authentication required." | |||
| @@ -2,8 +2,13 @@ from flask import request | |||
| from flask_restful import marshal_with | |||
| import services | |||
| from controllers.common.errors import FilenameNotExistsError | |||
| from controllers.web.error import FileTooLargeError, NoFileUploadedError, TooManyFilesError, UnsupportedFileTypeError | |||
| from controllers.common.errors import ( | |||
| FilenameNotExistsError, | |||
| FileTooLargeError, | |||
| NoFileUploadedError, | |||
| TooManyFilesError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from controllers.web.wraps import WebApiResource | |||
| from fields.file_fields import file_fields | |||
| from services.file_service import FileService | |||
| @@ -5,15 +5,17 @@ from flask_restful import marshal_with, reqparse | |||
| import services | |||
| from controllers.common import helpers | |||
| from controllers.common.errors import RemoteFileUploadError | |||
| from controllers.common.errors import ( | |||
| FileTooLargeError, | |||
| RemoteFileUploadError, | |||
| UnsupportedFileTypeError, | |||
| ) | |||
| from controllers.web.wraps import WebApiResource | |||
| from core.file import helpers as file_helpers | |||
| from core.helper import ssrf_proxy | |||
| from fields.file_fields import file_fields_with_signed_url, remote_file_info_fields | |||
| from services.file_service import FileService | |||
| from .error import FileTooLargeError, UnsupportedFileTypeError | |||
| class RemoteFileInfoApi(WebApiResource): | |||
| @marshal_with(remote_file_info_fields) | |||
| @@ -4,8 +4,8 @@ from unittest.mock import patch | |||
| import pytest | |||
| from werkzeug.exceptions import Forbidden | |||
| from controllers.common.errors import FilenameNotExistsError | |||
| from controllers.console.error import ( | |||
| from controllers.common.errors import ( | |||
| FilenameNotExistsError, | |||
| FileTooLargeError, | |||
| NoFileUploadedError, | |||
| TooManyFilesError, | |||