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
test: use sqlite3 session in test_metadata_nullable_bug (#38717)
Asuka Minatoe6efbb08df55
diff --git a/api/tests/unit_tests/services/test_metadata_nullable_bug.py b/api/tests/unit_tests/services/test_metadata_nullable_bug.pyindex cfd3d034df2..af898f3cb4a 100644--- a/api/tests/unit_tests/services/test_metadata_nullable_bug.py+++ b/api/tests/unit_tests/services/test_metadata_nullable_bug.py@@ -2,11 +2,17 @@ from typing import castfrom unittest.mock import Mockimport pytest+from sqlalchemy.orm import Sessionfrom models import Account, Tenantfrom services.entities.knowledge_entities.knowledge_entities import MetadataArgsfrom services.metadata_service import MetadataService+pytestmark = [+ pytest.mark.usefixtures("sqlite_session"),+ pytest.mark.parametrize("sqlite_session", [()], indirect=True),+]+def _make_account(account_id: str = "user-456", tenant_id: str = "tenant-123") -> Account:account = Account(name="Test User", email=f"{account_id}@example.com")@@ -27,7 +33,7 @@ class TestMetadataNullableBug:# This should fail because Pydantic expects non-None valuesMetadataArgs(type=None, name=None) # pyrefly: ignore[bad-argument-type]- def test_metadata_service_create_with_none_name_crashes(self) -> None:+ def test_metadata_service_create_with_none_name_crashes(self, sqlite_session: Session) -> None:"""Test that MetadataService.create_metadata crashes when name is None."""# Mock the MetadataArgs to bypass Pydantic validationmock_metadata_args = Mock()@@ -37,17 +43,21 @@ class TestMetadataNullableBug:account = _make_account()# This should crash with TypeError when calling len(None)with pytest.raises(TypeError, match="object of type 'NoneType' has no len"):- MetadataService.create_metadata("dataset-123", mock_metadata_args, account, "tenant-123", session=Mock())+ MetadataService.create_metadata(+ "dataset-123", mock_metadata_args, account, "tenant-123", session=sqlite_session+ )+ assert not sqlite_session.in_transaction()- def test_metadata_service_update_with_none_name_crashes(self) -> None:+ def test_metadata_service_update_with_none_name_crashes(self, sqlite_session: Session) -> None:"""Test that MetadataService.update_metadata_name crashes when name is None."""account = _make_account()none_name = cast(str, None)# This should crash with TypeError when calling len(None)with pytest.raises(TypeError, match="object of type 'NoneType' has no len"):MetadataService.update_metadata_name(- "dataset-123", "metadata-456", none_name, account, "tenant-123", session=Mock()+ "dataset-123", "metadata-456", none_name, account, "tenant-123", session=sqlite_session)+ assert not sqlite_session.in_transaction()def test_api_layer_now_uses_pydantic_validation(self) -> None:"""Verify that API layer relies on Pydantic validation instead of reqparse."""