Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Migration/Destinations/Appwrite.php
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ private function syncVectorDimension(Column|Attribute $resource, string $type, U
return;
}

if ((int) $table->getAttribute('dimension', 0) === $resource->getSize()) {
if ((int) $table->getAttribute('dimension', 0) !== 0) {
return;
}
Comment on lines +1338 to 1340

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.

P1 Stale Vector Dimension Persists

When an imported VectorsDB collection already has a non-zero archived dimension that differs from the vector column size, this guard now skips the sync that used to correct the mismatch. A collection archived with dimension: 256 and a vector column size of 1536 can leave the destination collection metadata at 256 after the vector column is created, so later vector writes or queries can validate against stale dimensions.

Suggested change
if ((int) $table->getAttribute('dimension', 0) !== 0) {
return;
}
if ((int) $table->getAttribute('dimension', 0) === $resource->getSize()) {
return;
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Migration/Destinations/Appwrite.php
Line: 1338-1340

Comment:
**Stale Vector Dimension Persists**

When an imported VectorsDB collection already has a non-zero archived `dimension` that differs from the vector column size, this guard now skips the sync that used to correct the mismatch. A collection archived with `dimension: 256` and a vector column size of `1536` can leave the destination collection metadata at `256` after the vector column is created, so later vector writes or queries can validate against stale dimensions.

```suggestion
        if ((int) $table->getAttribute('dimension', 0) === $resource->getSize()) {
            return;
        }
```

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code Fix in Codex

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Valid — but the suggested revert reintroduces the multi-vector overwrite from the #210 review. Fixed in the follow-up by keying the sync to the schema-defining embeddings column: it alone drives dimension (correcting mismatches and the placeholder), other vector columns never touch it.


Expand Down
10 changes: 7 additions & 3 deletions src/Migration/Resources/Database/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ public function setDimension(?int $dimension): self
*/
public function jsonSerialize(): array
{
return array_merge(parent::jsonSerialize(), [
'dimension' => $this->dimension,
]);
$data = parent::jsonSerialize();

if ($this->dimension !== null) {
$data['dimension'] = $this->dimension;
}

return $data;
}
}
2 changes: 1 addition & 1 deletion tests/Migration/Unit/Resources/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public function testDimensionDefaultsToNull(): void
]);

$this->assertNull($collection->getDimension());
$this->assertNull($collection->jsonSerialize()['dimension']);
$this->assertArrayNotHasKey('dimension', $collection->jsonSerialize());
}
}
Loading