发布

  • fix: auto-migrate LanceDB on 'contained null values' schema drift (#2702) (#2703)

    frostbyte_neo 发布于 2026-04-22 21:50:01 +00:00

    Summary

    Fixes #2702. LanceDBAdapter.create_data_points only treated "not found in target schema" as a recoverable schema drift. The inverse case
    — old rows lacking a field the current schema now requires to be
    non-null — raises "contained null values even though the field is marked non-null" from the Rust lance-file writer and was not matched,
    so the RuntimeError escaped and killed the uvicorn worker mid-batch.

    • cognee/infrastructure/databases/vector/lancedb/LanceDBAdapter.py
      extend the message match so both patterns route to the existing
      _migrate_collection_schema path (which rebuilds via Pydantic
      validation and fills defaults like feedback_weight=0.5).

    cognee/tests/unit/infrastructure/databases/vector/test_lancedb_schema_migration.py
    — adds test_null_in_non_null_field_triggers_migration (patches
    merge_insert to raise the Rust-side message once; verifies the row
    lands after migration).

    • pyproject.toml / uv.lock — bump 1.0.11.0.2.

    Test plan

    • pytest cognee/tests/unit/infrastructure/databases/vector/test_lancedb_schema_migration.py -v → 7 passed (6 prior + 1 new)
    • New test fails on main without the one-line match extension
      (verified locally by stashing the fix and re-running)
    • ruff check / ruff format clean on changed files

    Fixes #2702

    🤖 Generated with Claude Code

    Summary by CodeRabbit

    • Bug Fixes

    • Enhanced vector database adapter error handling to recover from
      additional schema-drift failure scenarios during data operations,
      improving overall system reliability.

    • Tests

    • Added regression test to validate vector database schema migration and
      error recovery behavior.

    • Chores

      • Version bumped to 1.0.2.
    下载附件