Skip to content

feat: Add timezone-aware datetime support for PostgreSQL - #10535

Closed
Cristhianzl wants to merge 10 commits into
mainfrom
cz/add-support-timezone
Closed

feat: Add timezone-aware datetime support for PostgreSQL#10535
Cristhianzl wants to merge 10 commits into
mainfrom
cz/add-support-timezone

Conversation

@Cristhianzl

@Cristhianzl Cristhianzl commented Nov 7, 2025

Copy link
Copy Markdown
Member

This pull request adds comprehensive timezone-aware datetime support for PostgreSQL compatibility across all major database models and updates the Alembic migration to reflect these changes. The main focus is to ensure all relevant timestamp fields in the models and database tables use timezone-aware datetimes, improving consistency and compatibility, especially when using asyncpg with PostgreSQL. Additionally, a new conftest file is introduced to support PostgreSQL-specific integration tests.

Database schema and model updates for timezone support:

  • Added a new Alembic migration (c8613607a100) that alters relevant datetime columns in the PostgreSQL database to use TIMESTAMP WITH TIME ZONE, and provides a downgrade path to revert to timezone-naive columns. The migration covers tables: user, apikey, flow, message, file, transaction, and vertex_build.
  • Updated all affected model fields in User, ApiKey, File, Flow, Message, Transaction, and VertexBuild to use SQLAlchemy's DateTime(timezone=True) for their datetime columns, ensuring the ORM layer matches the database schema. [1] [2] [3] [4] [5] [6] [7]

Codebase imports and consistency:

  • Added or reordered imports of DateTime from SQLAlchemy in all relevant model files to support the new timezone-aware columns. [1] [2] [3] [4] [5]

Testing infrastructure:

  • Introduced a new conftest.py for PostgreSQL driver integration tests, overriding the default app startup fixture to prevent interference with test database URLs.

Summary by CodeRabbit

  • Chores
    • Migrated database timestamps to timezone-aware format for PostgreSQL, enabling accurate time tracking across multiple time zones.
    • Updated datetime field storage to explicitly support timezone-aware operations throughout the system.
    • Added comprehensive test coverage for timezone-aware datetime handling with PostgreSQL verification.

@coderabbitai

coderabbitai Bot commented Nov 7, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request adds timezone-aware datetime support for PostgreSQL backends by introducing an Alembic migration that converts datetime columns to timezone-aware types, updating seven database models to explicitly specify DateTime(timezone=True) columns, and introducing comprehensive integration and unit tests to validate timezone handling across drivers and models.

Changes

Cohort / File(s) Summary
Alembic Migration
src/backend/base/langflow/alembic/versions/c8613607a100_add_timezone_support_for_asyncpg_.py
Adds database migration to convert datetime columns (create_at, updated_at, last_login_at, last_used_at, timestamp, created_at) to timezone-aware DateTime(timezone=True) across user, apikey, flow, message, file, transaction, and vertex_build tables for PostgreSQL only. Includes reversible downgrade to timezone-naive timestamps.
Database Model Updates
src/backend/base/langflow/services/database/models/user/model.py, src/backend/base/langflow/services/database/models/api_key/model.py, src/backend/base/langflow/services/database/models/file/model.py, src/backend/base/langflow/services/database/models/flow/model.py, src/backend/base/langflow/services/database/models/message/model.py, src/backend/base/langflow/services/database/models/transactions/model.py
Updates datetime fields across models to use explicit sa_column=Column(DateTime(timezone=True), ...) specifications while preserving default factories for UTC timestamp generation. Adds necessary SQLAlchemy DateTime imports.
Vertex Builds Model
src/backend/base/langflow/services/database/models/vertex_builds/model.py
Converts timestamp to timezone-aware DateTime; introduces new fields (params, valid, flow_id) with associated validation and serialization logic; adds Config with arbitrary_types_allowed; includes flow_id validator for UUID coercion and field serializers for timestamp, data, artifacts, and params.
Test Infrastructure
src/backend/tests/integration/drivers/conftest.py
Adds pytest fixture override to prevent loading client fixture during PostgreSQL driver tests, allowing tests to manage database connections independently.
Integration Tests
src/backend/tests/integration/drivers/test_postgresql_drivers.py
Adds PostgreSQL driver compatibility tests covering asyncpg and psycopg backends, validating timezone-aware datetime creation, schema verification (TIMESTAMP WITH TIME ZONE), bulk inserts, and storage format via information_schema queries.
Unit Tests
src/backend/tests/unit/test_datetime_timezone.py
Adds comprehensive async tests validating timezone-aware datetime handling across User, ApiKey, Flow, and Message models, including tzinfo preservation, comparison operations, PostgreSQL timestamptz schema verification, ISO 8601 serialization, and bulk insert operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Focus areas requiring extra attention:
    • Verify consistency of timezone-aware column specifications across all six updated models for correctness and completeness
    • Review vertex_builds model for correctness of new validators (flow_id UUID coercion) and serializer implementations (timestamp tzinfo handling)
    • Validate test coverage for both drivers (asyncpg and psycopg) properly exercises timezone functionality
    • Confirm migration upgrade/downgrade logic handles all affected columns and tables without data loss
    • Cross-check that all datetime fields across models that should be timezone-aware have been updated

Suggested labels

enhancement, size:XXL, lgtm

Suggested reviewers

  • edwinjosechittilappilly
  • ogabrielluiz
  • jordanrfrazier

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)
Check name Status Explanation Resolution
Test Coverage For New Implementations ❌ Error Test files lack pytestmark for async execution and init.py is missing from drivers directory, preventing proper test discovery and execution. Add pytestmark = pytest.mark.asyncio to test_datetime_timezone.py and create init.py in src/backend/tests/integration/drivers/.
Test Quality And Coverage ⚠️ Warning PR introduces comprehensive timezone-aware datetime tests but has critical issues: test_datetime_timezone.py lacks @pytest.mark.asyncio decorators on async functions, test_postgresql_drivers.py has inconsistent marking, and src/backend/tests/integration/drivers/ lacks init.py file. Add @pytest.mark.asyncio decorators to async test functions, ensure consistent pytest marking across test modules, create init.py in drivers directory, and verify tests execute locally before merging.
Test File Naming And Structure ⚠️ Warning Test files violate pytest best practices: missing init.py in drivers directory (INP001 error) and async test functions lack pytest.mark.asyncio marker. Create init.py in src/backend/tests/integration/drivers/ and add pytestmark = pytest.mark.asyncio to test_datetime_timezone.py after imports.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding timezone-aware datetime support for PostgreSQL across models and schema.
Docstring Coverage ✅ Passed Docstring coverage is 90.48% which is sufficient. The required threshold is 80.00%.
Excessive Mock Usage Warning ✅ Passed Both test files use real database objects and actual ORM operations with zero mock frameworks, demonstrating strong integration test design focused on real behavior validation rather than mocked abstractions.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cz/add-support-timezone

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 7, 2025
@codecov

codecov Bot commented Nov 7, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 33.71%. Comparing base (0e03376) to head (0f17b50).
⚠️ Report is 1 commits behind head on main.

❌ Your project status has failed because the head coverage (40.81%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10535      +/-   ##
==========================================
- Coverage   34.25%   33.71%   -0.54%     
==========================================
  Files        1409     1356      -53     
  Lines       66892    65334    -1558     
  Branches     9860     9465     -395     
==========================================
- Hits        22912    22030     -882     
+ Misses      42787    42278     -509     
+ Partials     1193     1026     -167     
Flag Coverage Δ
lfx 40.81% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...langflow/services/database/models/api_key/model.py 100.00% <100.00%> (ø)
...se/langflow/services/database/models/file/model.py 100.00% <100.00%> (ø)
...se/langflow/services/database/models/flow/model.py 76.66% <100.00%> (ø)
...langflow/services/database/models/message/model.py 80.88% <100.00%> (ø)
...low/services/database/models/transactions/model.py 92.52% <100.00%> (+0.07%) ⬆️
...se/langflow/services/database/models/user/model.py 100.00% <100.00%> (ø)
...ow/services/database/models/vertex_builds/model.py 96.15% <100.00%> (ø)

... and 178 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 7, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 403b939 and 69521c5.

📒 Files selected for processing (11)
  • src/backend/base/langflow/alembic/versions/c8613607a100_add_timezone_support_for_asyncpg_.py (1 hunks)
  • src/backend/base/langflow/services/database/models/api_key/model.py (1 hunks)
  • src/backend/base/langflow/services/database/models/file/model.py (2 hunks)
  • src/backend/base/langflow/services/database/models/flow/model.py (2 hunks)
  • src/backend/base/langflow/services/database/models/message/model.py (2 hunks)
  • src/backend/base/langflow/services/database/models/transactions/model.py (1 hunks)
  • src/backend/base/langflow/services/database/models/user/model.py (2 hunks)
  • src/backend/base/langflow/services/database/models/vertex_builds/model.py (1 hunks)
  • src/backend/tests/integration/drivers/conftest.py (1 hunks)
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py (1 hunks)
  • src/backend/tests/unit/test_datetime_timezone.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
{src/backend/**/*.py,tests/**/*.py,Makefile}

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

{src/backend/**/*.py,tests/**/*.py,Makefile}: Run make format_backend to format Python code before linting or committing changes
Run make lint to perform linting checks on backend Python code

Files:

  • src/backend/tests/integration/drivers/conftest.py
  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/base/langflow/services/database/models/flow/model.py
  • src/backend/base/langflow/services/database/models/transactions/model.py
  • src/backend/base/langflow/services/database/models/file/model.py
  • src/backend/base/langflow/services/database/models/api_key/model.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
  • src/backend/base/langflow/services/database/models/message/model.py
  • src/backend/base/langflow/alembic/versions/c8613607a100_add_timezone_support_for_asyncpg_.py
  • src/backend/base/langflow/services/database/models/user/model.py
  • src/backend/base/langflow/services/database/models/vertex_builds/model.py
src/backend/tests/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/testing.mdc)

src/backend/tests/**/*.py: Unit tests for backend code must be located in the 'src/backend/tests/' directory, with component tests organized by component subdirectory under 'src/backend/tests/unit/components/'.
Test files should use the same filename as the component under test, with an appropriate test prefix or suffix (e.g., 'my_component.py' → 'test_my_component.py').
Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.
When writing component tests, inherit from the appropriate base class in 'src/backend/tests/base.py' (ComponentTestBase, ComponentTestBaseWithClient, or ComponentTestBaseWithoutClient) and provide the required fixtures: 'component_class', 'default_kwargs', and 'file_names_mapping'.
Each test in backend Python test files should have a clear docstring explaining its purpose, and complex setups or mocks should be well-commented.
Test both sync and async code paths in backend Python tests, using '@pytest.mark.asyncio' for async tests.
Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.
Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.
Validate input/output behavior and test component initialization and configuration in backend Python tests.
Use the 'no_blockbuster' pytest marker to skip the blockbuster plugin in tests when necessary.
Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.
Test error handling by mocking internal functions using monkeypatch in backend Python tests.
Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.
Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.
Test Langflow's Messag...

Files:

  • src/backend/tests/integration/drivers/conftest.py
  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
src/backend/tests/unit/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

Test component integration within flows using create_flow, build_flow, and get_build_events utilities

Files:

  • src/backend/tests/unit/test_datetime_timezone.py
src/backend/base/langflow/services/database/models/**/*.py

📄 CodeRabbit inference engine (.cursor/rules/backend_development.mdc)

Place database models in src/backend/base/langflow/services/database/models/

Files:

  • src/backend/base/langflow/services/database/models/flow/model.py
  • src/backend/base/langflow/services/database/models/transactions/model.py
  • src/backend/base/langflow/services/database/models/file/model.py
  • src/backend/base/langflow/services/database/models/api_key/model.py
  • src/backend/base/langflow/services/database/models/message/model.py
  • src/backend/base/langflow/services/database/models/user/model.py
  • src/backend/base/langflow/services/database/models/vertex_builds/model.py
🧠 Learnings (19)
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Use the 'client' fixture (an async httpx.AsyncClient) for API tests in backend Python tests, as defined in 'src/backend/tests/conftest.py'.

Applied to files:

  • src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to tests/**/*.py : Use the client fixture from conftest.py for API endpoint tests

Applied to files:

  • src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to conftest.py : Use 'conftest.py' to define and share fixtures for backend Python tests.

Applied to files:

  • src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test resource cleanup in backend Python tests by using fixtures that ensure proper initialization and cleanup of resources.

Applied to files:

  • src/backend/tests/integration/drivers/conftest.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Mock external dependencies appropriately in backend Python tests to isolate unit tests from external services.

Applied to files:

  • src/backend/tests/integration/drivers/conftest.py
  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to tests/**/*.py : Use in-memory SQLite for database tests

Applied to files:

  • src/backend/tests/integration/drivers/conftest.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test timeout and performance constraints in backend Python tests using 'asyncio.wait_for' and timing assertions.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Be aware of ContextVar propagation in async tests; test both direct event loop execution and 'asyncio.to_thread' scenarios to ensure proper context isolation.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test both sync and async code paths in backend Python tests, using 'pytest.mark.asyncio' for async tests.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/tests/unit/components/**/*.py : Create comprehensive unit tests for all new components

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Validate input/output behavior and test component initialization and configuration in backend Python tests.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test error handling by mocking internal functions using monkeypatch in backend Python tests.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Use 'anyio' and 'aiofiles' for async file operations in backend Python tests that involve file handling.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test real-time event streaming endpoints in backend Python tests by consuming and validating NDJSON event streams.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test error handling and edge cases in backend Python tests, including using 'pytest.raises' and asserting error messages.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/unit/test_database.py : For database-related tests that may fail in batch runs but pass individually, consider running them sequentially and be aware of this behavior when writing such tests.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test Langflow's REST API endpoints in backend Python tests using the async client fixture and asserting response codes and payloads.

Applied to files:

  • src/backend/tests/unit/test_datetime_timezone.py
  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
📚 Learning: 2025-07-18T18:25:54.486Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/backend_development.mdc:0-0
Timestamp: 2025-07-18T18:25:54.486Z
Learning: Applies to src/backend/base/langflow/services/database/models/**/*.py : Place database models in src/backend/base/langflow/services/database/models/

Applied to files:

  • src/backend/base/langflow/services/database/models/flow/model.py
  • src/backend/base/langflow/services/database/models/transactions/model.py
  • src/backend/base/langflow/services/database/models/file/model.py
  • src/backend/base/langflow/services/database/models/vertex_builds/model.py
📚 Learning: 2025-07-21T14:16:14.125Z
Learnt from: CR
Repo: langflow-ai/langflow PR: 0
File: .cursor/rules/testing.mdc:0-0
Timestamp: 2025-07-21T14:16:14.125Z
Learning: Applies to src/backend/tests/**/*.py : Test backward compatibility across Langflow versions in backend Python tests by mapping component files to supported versions using 'VersionComponentMapping'.

Applied to files:

  • src/backend/tests/integration/drivers/test_postgresql_drivers.py
🧬 Code graph analysis (3)
src/backend/tests/unit/test_datetime_timezone.py (6)
src/backend/base/langflow/services/database/models/api_key/model.py (1)
  • ApiKey (25-36)
src/backend/base/langflow/services/database/models/flow/model.py (1)
  • Flow (188-214)
src/backend/base/langflow/services/database/models/message/model.py (1)
  • MessageTable (126-171)
src/backend/base/langflow/services/database/models/user/model.py (1)
  • User (25-55)
src/backend/base/langflow/services/database/utils.py (1)
  • session_getter (65-74)
src/backend/base/langflow/services/deps.py (1)
  • get_db_service (138-147)
src/backend/base/langflow/services/database/models/transactions/model.py (1)
src/backend/base/langflow/serialization/serialization.py (3)
  • get_max_items_length (37-39)
  • get_max_text_length (31-33)
  • serialize (253-305)
src/backend/base/langflow/services/database/models/vertex_builds/model.py (1)
src/backend/base/langflow/serialization/serialization.py (3)
  • get_max_items_length (37-39)
  • get_max_text_length (31-33)
  • serialize (253-305)
🪛 GitHub Actions: Ruff Style Check
src/backend/tests/integration/drivers/conftest.py

[error] 1-1: INP001: File is part of an implicit namespace package. Add an init.py.

🪛 GitHub Check: Ruff Style Check (3.13)
src/backend/tests/integration/drivers/conftest.py

[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/conftest.py:1:1: INP001 File src/backend/tests/integration/drivers/conftest.py is part of an implicit namespace package. Add an __init__.py.

src/backend/tests/integration/drivers/test_postgresql_drivers.py

[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/test_postgresql_drivers.py:1:1: INP001 File src/backend/tests/integration/drivers/test_postgresql_drivers.py is part of an implicit namespace package. Add an __init__.py.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 3
  • GitHub Check: Run Backend Tests / Integration Tests - Python 3.10
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 5
  • GitHub Check: Run Frontend Tests / Determine Test Suites and Shard Distribution
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 4
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 2
  • GitHub Check: Run Backend Tests / Unit Tests - Python 3.10 - Group 1
  • GitHub Check: Run Backend Tests / LFX Tests - Python 3.10
  • GitHub Check: Run Backend Tests / Test CLI - Python 3.10
  • GitHub Check: Lint Backend / Run Mypy (3.13)
  • GitHub Check: Lint Backend / Run Mypy (3.10)
  • GitHub Check: Lint Backend / Run Mypy (3.12)
  • GitHub Check: Test Starter Templates
  • GitHub Check: Update Component Index
  • GitHub Check: Update Starter Projects
  • GitHub Check: Optimize new Python code in this PR
🔇 Additional comments (13)
src/backend/base/langflow/services/database/models/api_key/model.py (1)

20-20: LGTM! Timezone-aware mapping aligns with migration.

The last_used_at field correctly maps to a timezone-aware SQLAlchemy column, matching the migration changes for PostgreSQL.

src/backend/base/langflow/services/database/models/transactions/model.py (2)

5-6: LGTM! Import updated to support timezone-aware column.

The DateTime import is correctly added to support the sa_column usage in the timestamp field.


12-14: LGTM! Timezone-aware timestamp aligns with migration.

The timestamp field correctly maps to a timezone-aware SQLAlchemy column with UTC default, matching the migration for the transaction table.

src/backend/base/langflow/services/database/models/file/model.py (2)

4-4: LGTM! Import updated to support timezone-aware columns.

The DateTime import is correctly added to support the sa_column usage in the timestamp fields.


17-22: LGTM! Timezone-aware timestamps align with migration.

Both created_at and updated_at fields correctly map to timezone-aware SQLAlchemy columns with UTC defaults, matching the migration for the file table.

src/backend/base/langflow/services/database/models/message/model.py (2)

7-7: LGTM! Import updated to support timezone-aware column.

The DateTime import is correctly added to support the sa_column usage in the timestamp field.


19-20: LGTM! Timezone-aware timestamp aligns with migration.

The timestamp field correctly maps to a timezone-aware SQLAlchemy column, matching the migration for the message table. The existing serializer at lines 35-45 properly handles timezone conversion.

src/backend/base/langflow/services/database/models/vertex_builds/model.py (2)

5-5: LGTM! Import updated to support timezone-aware column.

The DateTime import is correctly added to support the sa_column usage in the timestamp field.


12-14: LGTM! Timezone-aware timestamp aligns with migration.

The timestamp field correctly maps to a timezone-aware SQLAlchemy column with UTC default, matching the migration for the vertex_build table. The serializer at lines 35-40 properly handles timezone conversion.

src/backend/base/langflow/alembic/versions/c8613607a100_add_timezone_support_for_asyncpg_.py (2)

21-111: LGTM! Migration correctly implements PostgreSQL-specific timezone support.

The upgrade function properly:

  • Gates changes to PostgreSQL only (line 26), avoiding SQLite incompatibility
  • Converts datetime columns to timezone-aware types across all affected tables
  • Preserves nullable constraints for each column
  • Aligns with the model changes in this PR

114-203: LGTM! Downgrade path is complete and correct.

The downgrade function provides a proper rollback path by reverting all timezone-aware columns back to timezone-naive types while preserving the original nullable constraints.

src/backend/base/langflow/services/database/models/flow/model.py (2)

14-14: LGTM! Imports updated to support timezone-aware column.

The DateTime import is correctly added to support the sa_column usage in the updated_at field.


43-45: LGTM! Timezone-aware timestamp aligns with migration.

The updated_at field correctly maps to a timezone-aware SQLAlchemy column with UTC default, matching the migration for the flow table. The serializer at lines 166-175 properly handles timezone conversion to ISO format.

Comment on lines +1 to +18
"""Conftest for PostgreSQL driver tests.

This conftest overrides the _start_app fixture from the parent integration/conftest.py
to prevent it from loading the client fixture, which would override the database URL.
"""

import pytest


@pytest.fixture(autouse=True)
def _start_app():
"""Override parent _start_app fixture to skip client loading.

PostgreSQL driver tests create their own database connections
and don't need the app client fixture.
"""
# Do nothing - this prevents the parent fixture from running
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Add __init__.py to resolve namespace package error.

The static analysis tool and pipeline both flag that this file is part of an implicit namespace package. To resolve this, create an __init__.py file in the src/backend/tests/integration/drivers/ directory.

To fix this, create an empty __init__.py file:

#!/bin/bash
touch src/backend/tests/integration/drivers/__init__.py
🧰 Tools
🪛 GitHub Actions: Ruff Style Check

[error] 1-1: INP001: File is part of an implicit namespace package. Add an init.py.

🪛 GitHub Check: Ruff Style Check (3.13)

[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/conftest.py:1:1: INP001 File src/backend/tests/integration/drivers/conftest.py is part of an implicit namespace package. Add an __init__.py.

🤖 Prompt for AI Agents
In src/backend/tests/integration/drivers/conftest.py lines 1-18: static analysis
reports this module is part of an implicit namespace package; fix by adding an
empty __init__.py in the same directory
(src/backend/tests/integration/drivers/__init__.py) so the package is explicit
and import resolution/static analysis pass; create the file with normal text
file permissions (empty content is fine).

Comment on lines +1 to +12
"""Integration tests for PostgreSQL driver compatibility.

This test suite validates that DateTime(timezone=True) works with:
- asyncpg (async PostgreSQL driver)
- psycopg (modern async/sync driver)
- psycopg2 (legacy sync driver)

These tests only run on PostgreSQL databases.

Related to: Migration c8613607a100_add_timezone_support_for_asyncpg
GitHub Issue: Verizon case - asyncpg compatibility
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add package initializer for Ruff compliance.

Ruff is failing with INP001 because src/backend/tests/integration/drivers/ is now an implicit namespace package. Please add an empty __init__.py (or otherwise adjust the package layout) so the linter passes.

🧰 Tools
🪛 GitHub Check: Ruff Style Check (3.13)

[failure] 1-1: Ruff (INP001)
src/backend/tests/integration/drivers/test_postgresql_drivers.py:1:1: INP001 File src/backend/tests/integration/drivers/test_postgresql_drivers.py is part of an implicit namespace package. Add an __init__.py.

🤖 Prompt for AI Agents
In src/backend/tests/integration/drivers/ around lines 1-12 the directory is an
implicit namespace package causing Ruff INP001; add a new file
src/backend/tests/integration/drivers/__init__.py (can be empty or contain a
brief module docstring or __all__ = []) to make it an explicit package, commit
that file so the linter recognizes the package and rerun tests/CI.

Comment on lines +23 to +30
@pytest.mark.api_key_required
async def test_user_create_with_timezone_aware_datetime():
"""Test that User model accepts timezone-aware datetimes."""
now = datetime.now(timezone.utc)

async with session_getter(get_db_service()) as session:
user = User(
id=uuid4(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Mark async tests with pytest.mark.asyncio.

Every test here is async def, but there’s no pytest.mark.asyncio (module-level or per test). Per our testing guidelines this marker is required so pytest-asyncio actually runs these coroutines instead of erroring out. Please add a module-level mark right after the imports, e.g.:

 from uuid import uuid4
 
 import pytest
 
+pytestmark = pytest.mark.asyncio
+

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/backend/tests/unit/test_datetime_timezone.py around lines 23 to 30, the
async test functions lack the pytest-asyncio marker so pytest won't run
coroutines; add the required marker by either applying @pytest.mark.asyncio to
each async test or (preferred) adding a module-level pytestmark =
pytest.mark.asyncio immediately after the imports to mark all tests in this file
as asyncio.

@github-actions github-actions Bot added the lgtm This PR has been approved by a maintainer label Nov 7, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 10, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 10, 2025
@github-actions

github-actions Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 17%
17.44% (4975/28524) 10.76% (2363/21956) 11.55% (722/6246)

Unit Test Results

Tests Skipped Failures Errors Time
1999 0 💤 0 ❌ 0 🔥 25.709s ⏱️


# Only apply changes if using PostgreSQL
# SQLite and other databases don't have timezone-aware datetime types
if conn.dialect.name == "postgresql":

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Cristhianzl let's add a paragraph explaining why we're doing this migration somewhere in this file. I think that'll be good practice for future changes, and easier than digging through commit history to find a PR description (especially if we do any refactoring).

@Cristhianzl Cristhianzl closed this Jan 5, 2026
@Cristhianzl Cristhianzl reopened this Jan 6, 2026
@Cristhianzl Cristhianzl closed this Jan 6, 2026
@Cristhianzl Cristhianzl reopened this Jan 15, 2026
@github-actions github-actions Bot removed the enhancement New feature or request label Jan 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Migration validation check failed to run properly
Error: Unexpected end of JSON input

@github-actions github-actions Bot added the enhancement New feature or request label Jan 15, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Migration validation check failed to run properly
Error: Unexpected end of JSON input

@github-actions github-actions Bot added the enhancement New feature or request label Jan 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Migration validation check failed to run properly
Error: Unexpected end of JSON input

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Migration validation check failed to run properly
Error: Unexpected end of JSON input

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Jan 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Migration validation check failed to run properly
Error: Unexpected end of JSON input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants