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
feat(api): return account created_at from the OAuth provider account endpoint (#43744)
L1nSn0w6a0d228ebfeb
diff --git a/api/controllers/console/auth/oauth_server.py b/api/controllers/console/auth/oauth_server.pyindex 15b1c867235..501ee568379 100644--- a/api/controllers/console/auth/oauth_server.py+++ b/api/controllers/console/auth/oauth_server.py@@ -1,9 +1,10 @@+from datetime import datetimefrom http import HTTPStatusfrom typing import Any, Neverfrom flask import Response, jsonify, requestfrom flask_restx import Resource-from pydantic import BaseModel, ValidationError+from pydantic import BaseModel, ValidationError, field_validatorfrom werkzeug.exceptions import BadRequest, NotFound, UnprocessableEntityfrom controllers.common.schema import register_response_schema_models, register_schema_models@@ -11,7 +12,7 @@ from controllers.console.flask_admission import console_account_admissionfrom controllers.console.wraps import setup_requiredfrom extensions.ext_application_services import application_servicesfrom fields.base import ResponseModel-from libs.helper import dump_response+from libs.helper import dump_response, to_timestampfrom machinery.context import RequestContextfrom services.oauth_server_service import (OAuthServerClientNotFoundError,@@ -65,6 +66,12 @@ class OAuthProviderAccountResponse(ResponseModel):avatar: str | None = Noneinterface_language: str | Nonetimezone: str | None+ created_at: int++ @field_validator("created_at", mode="before")+ @classmethod+ def _normalize_timestamp(cls, value: datetime | int) -> int:+ return to_timestamp(value)register_schema_models(console_ns, OAuthClientPayload, OAuthProviderRequest, OAuthTokenRequest)diff --git a/api/openapi/markdown/console-openapi.md b/api/openapi/markdown/console-openapi.mdindex 48d5db25c49..be1a3ffb051 100644--- a/api/openapi/markdown/console-openapi.md+++ b/api/openapi/markdown/console-openapi.md@@ -21128,6 +21128,7 @@ Coarse node-level status used by Inspector to pick a banner.| Name | Type | Description | Required || ---- | ---- | ----------- | -------- || avatar | string | | No |+| created_at | integer | | Yes || email | string | | Yes || id | string | | Yes || interface_language | string | | Yes |diff --git a/api/repositories/oauth_server_repository.py b/api/repositories/oauth_server_repository.pyindex 9f9e7fa8570..2edee39be7b 100644--- a/api/repositories/oauth_server_repository.py+++ b/api/repositories/oauth_server_repository.py@@ -72,6 +72,7 @@ class SQLAlchemyOAuthServerRepository(OAuthServerRepository):Account.interface_language,Account.timezone,Account.status,+ Account.created_at,).where(Account.id == account_id)with self._session_factory() as session:@@ -86,6 +87,7 @@ class SQLAlchemyOAuthServerRepository(OAuthServerRepository):interface_language=row.interface_language,timezone=row.timezone,status=OAuthProviderAccountStatus(row.status.value),+ created_at=row.created_at,)diff --git a/api/services/entities/oauth_server_entities.py b/api/services/entities/oauth_server_entities.pyindex 25194cf1795..a51c34280bd 100644--- a/api/services/entities/oauth_server_entities.py+++ b/api/services/entities/oauth_server_entities.py@@ -2,6 +2,7 @@from collections.abc import Mappingfrom dataclasses import dataclass+from datetime import datetimefrom enum import StrEnum@@ -58,6 +59,7 @@ class OAuthProviderAccount:avatar: str | Noneinterface_language: str | Nonetimezone: str | None+ created_at: datetime@dataclass(frozen=True, slots=True)@@ -69,3 +71,4 @@ class OAuthProviderAccountRecord:interface_language: str | Nonetimezone: str | Nonestatus: OAuthProviderAccountStatus+ created_at: datetimediff --git a/api/services/oauth_server_service.py b/api/services/oauth_server_service.pyindex af5bef2f5fd..9c3abff2621 100644--- a/api/services/oauth_server_service.py+++ b/api/services/oauth_server_service.py@@ -143,6 +143,7 @@ class OAuthServerService:avatar=account.avatar,interface_language=account.interface_language,timezone=account.timezone,+ created_at=account.created_at,)def _require_provider_app(self, client_id: str) -> OAuthProviderAppRecord:diff --git a/api/tests/test_containers_integration_tests/controllers/console/auth/test_oauth_server.py b/api/tests/test_containers_integration_tests/controllers/console/auth/test_oauth_server.pyindex a4cd1b71973..9e87503c726 100644--- a/api/tests/test_containers_integration_tests/controllers/console/auth/test_oauth_server.py+++ b/api/tests/test_containers_integration_tests/controllers/console/auth/test_oauth_server.py@@ -1,5 +1,6 @@"""Controller integration tests for console OAuth server routes."""+from datetime import UTC, datetimefrom types import SimpleNamespacefrom unittest.mock import MagicMock, patch@@ -259,6 +260,7 @@ def test_oauth_account_successful_retrieval(avatar=None,interface_language=None,timezone=None,+ created_at=datetime(2024, 1, 2, 3, 4, 5, tzinfo=UTC),)with patch(@@ -279,6 +281,7 @@ def test_oauth_account_successful_retrieval("avatar": None,"interface_language": None,"timezone": None,+ "created_at": 1704164645,}diff --git a/api/tests/unit_tests/controllers/console/auth/test_oauth_server.py b/api/tests/unit_tests/controllers/console/auth/test_oauth_server.pyindex 2718e600204..61e78d6b3f6 100644--- a/api/tests/unit_tests/controllers/console/auth/test_oauth_server.py+++ b/api/tests/unit_tests/controllers/console/auth/test_oauth_server.py@@ -1,3 +1,4 @@+from datetime import UTC, datetimefrom http import HTTPStatusfrom inspect import unwrapfrom types import SimpleNamespace@@ -132,6 +133,7 @@ def test_account_endpoint_parses_bearer_token_and_serializes_account() -> None:avatar="avatar",interface_language="en-US",timezone="UTC",+ created_at=datetime(2024, 1, 2, 3, 4, 5, tzinfo=UTC),)with (@@ -151,6 +153,7 @@ def test_account_endpoint_parses_bearer_token_and_serializes_account() -> None:"avatar": "avatar","interface_language": "en-US","timezone": "UTC",+ "created_at": 1704164645,},HTTPStatus.OK,)@@ -167,6 +170,7 @@ def test_account_endpoint_serializes_nullable_account_preferences() -> None:avatar=None,interface_language=None,timezone=None,+ created_at=datetime(2024, 1, 2, 3, 4, 5, tzinfo=UTC),)with (@@ -186,6 +190,7 @@ def test_account_endpoint_serializes_nullable_account_preferences() -> None:"avatar": None,"interface_language": None,"timezone": None,+ "created_at": 1704164645,},HTTPStatus.OK,)diff --git a/api/tests/unit_tests/repositories/test_oauth_server_repository.py b/api/tests/unit_tests/repositories/test_oauth_server_repository.pyindex fc75780803b..8b71fa75bb6 100644--- a/api/tests/unit_tests/repositories/test_oauth_server_repository.py+++ b/api/tests/unit_tests/repositories/test_oauth_server_repository.py@@ -1,4 +1,5 @@import uuid+from datetime import datetimefrom unittest.mock import MagicMock, patchimport pytest@@ -81,6 +82,7 @@ def test_get_account_by_id_maps_record(timezone="UTC",status=status,)+ account.created_at = datetime(2024, 1, 2, 3, 4, 5)with sqlite_session_factory.begin() as session:session.add(account)session.flush()@@ -96,6 +98,7 @@ def test_get_account_by_id_maps_record(interface_language="en-US",timezone="UTC",status=expected_status,+ created_at=datetime(2024, 1, 2, 3, 4, 5),)diff --git a/api/tests/unit_tests/services/test_oauth_server_service.py b/api/tests/unit_tests/services/test_oauth_server_service.pyindex 4eb1b8e5eb2..44dba89e249 100644--- a/api/tests/unit_tests/services/test_oauth_server_service.py+++ b/api/tests/unit_tests/services/test_oauth_server_service.py@@ -1,3 +1,4 @@+from datetime import datetimefrom unittest.mock import MagicMockimport pytest@@ -184,6 +185,7 @@ def test_get_account_returns_active_account_without_requiring_workspace_membershinterface_language="en-US",timezone="UTC",status=OAuthProviderAccountStatus.ACTIVE,+ created_at=datetime(2024, 1, 2, 3, 4, 5),)assert oauth_server.get_account(client_id="client-1", access_token="access-1") == OAuthProviderAccount(@@ -193,6 +195,7 @@ def test_get_account_returns_active_account_without_requiring_workspace_membershavatar=None,interface_language="en-US",timezone="UTC",+ created_at=datetime(2024, 1, 2, 3, 4, 5),)tokens.resolve_account_id.assert_called_once_with("client-1", "access-1")repository.get_account_by_id.assert_called_once_with("account-1")@@ -244,6 +247,7 @@ def test_get_account_rejects_inactive_account(interface_language=None,timezone=None,status=status,+ created_at=datetime(2024, 1, 2, 3, 4, 5),)with pytest.raises(OAuthServerUnauthorizedError, match=message):diff --git a/packages/contracts/generated/api/console/oauth/types.gen.ts b/packages/contracts/generated/api/console/oauth/types.gen.tsindex d42b16324b5..a04666d9c0f 100644--- a/packages/contracts/generated/api/console/oauth/types.gen.ts+++ b/packages/contracts/generated/api/console/oauth/types.gen.ts@@ -40,6 +40,7 @@ export type OAuthClientPayload = {export type OAuthProviderAccountResponse = {avatar?: string | null+ created_at: numberemail: stringid: stringinterface_language: string | nulldiff --git a/packages/contracts/generated/api/console/oauth/zod.gen.ts b/packages/contracts/generated/api/console/oauth/zod.gen.tsindex 23bde3c453e..2357de3c1b9 100644--- a/packages/contracts/generated/api/console/oauth/zod.gen.ts+++ b/packages/contracts/generated/api/console/oauth/zod.gen.ts@@ -60,6 +60,7 @@ export const zOAuthClientPayload = z.object({*/export const zOAuthProviderAccountResponse = z.object({avatar: z.string().nullish(),+ created_at: z.int(),email: z.string(),id: z.string(),interface_language: z.string().nullable(),