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
refactor(web): dep-inject the passport query with @model_validate (#41845)
Eddy ZHANGd69b19b5678c
diff --git a/api/controllers/web/passport.py b/api/controllers/web/passport.pyindex 3e4a7960984..46482b9c53e 100644--- a/api/controllers/web/passport.py+++ b/api/controllers/web/passport.py@@ -5,6 +5,7 @@ from werkzeug.exceptions import NotFound, Unauthorizedfrom constants import HEADER_NAME_APP_CODEfrom controllers.common.schema import query_params_from_model, register_response_schema_models, register_schema_models+from controllers.console.wraps import model_validatefrom controllers.web import web_nsfrom controllers.web.error import WebAppAuthRequiredErrorfrom extensions.ext_application_services import application_services@@ -48,12 +49,12 @@ class PassportResource(Resource):})@web_ns.response(200, "Passport retrieved successfully", web_ns.models[PassportAccessTokenResponse.__name__])- def get(self):+ @model_validate(PassportQuery)+ def get(self, query: PassportQuery):app_code = request.headers.get(HEADER_NAME_APP_CODE)if app_code is None:raise Unauthorized("X-App-Code header is missing.")- query = PassportQuery.model_validate(request.args.to_dict(flat=True))passport_request = WebPassportRequest(app_code=app_code,user_session_id=query.user_id,diff --git a/api/tests/unit_tests/controllers/web/test_web_passport.py b/api/tests/unit_tests/controllers/web/test_web_passport.pyindex 9ac0b731a3a..fd6cd80d062 100644--- a/api/tests/unit_tests/controllers/web/test_web_passport.py+++ b/api/tests/unit_tests/controllers/web/test_web_passport.py@@ -1,6 +1,5 @@"""Unit tests for the thin web-passport Flask adapter."""-from inspect import unwrapfrom types import SimpleNamespacefrom unittest.mock import MagicMock, patch@@ -31,7 +30,7 @@ def test_passport_resource_parses_input_and_serializes_result(app: Flask) -> Nonpatch("controllers.web.passport.application_services", return_value=services),patch("controllers.web.passport.extract_webapp_access_token", return_value="login-token"),):- result = unwrap(PassportResource.get)(PassportResource())+ result = PassportResource().get()assert result == {"access_token": "issued-token"}service.issue.assert_called_once_with(@@ -41,7 +40,7 @@ def test_passport_resource_parses_input_and_serializes_result(app: Flask) -> Nondef test_passport_resource_requires_app_code(app: Flask) -> None:with app.test_request_context("/passport"), pytest.raises(Unauthorized, match="X-App-Code"):- unwrap(PassportResource.get)(PassportResource())+ PassportResource().get()@pytest.mark.parametrize(@@ -66,4 +65,4 @@ def test_passport_resource_translates_application_errors(patch("controllers.web.passport.application_services", return_value=services),pytest.raises(http_error),):- unwrap(PassportResource.get)(PassportResource())+ PassportResource().get()