Skip to content

Fix empty split database metadata reports#197

Closed
abnegate wants to merge 1 commit into
mainfrom
fix/empty-split-database-report
Closed

Fix empty split database metadata reports#197
abnegate wants to merge 1 commit into
mainfrom
fix/empty-split-database-report

Conversation

@abnegate

Copy link
Copy Markdown
Member

What\n- Treat missing split database metadata collections as empty during Appwrite database-source reports.\n- Add regressions for DocumentsDB reports with no collection metadata table and no indexes metadata table.\n\n## Why\nCloud Backups E2E for DocumentsDB archive reports can request the index resource even when the source collection has no indexes. With DB 6 / split DocumentsDB metadata, counting a missing indexes collection throws Collection not found and leaves the archive pending.\n\n## Validation\n- vendor/bin/phpunit --configuration phpunit.xml tests/Migration/Unit/Sources/AppwriteDatabaseReaderTest.php\n- composer lint\n- composer check\n- docker compose exec tests php vendor/bin/phpunit

Copilot AI review requested due to automatic review settings June 19, 2026 11:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Treats a missing split-DB metadata collection as an empty result rather than a fatal error during Appwrite database-source reports, fixing Cloud Backups E2E failures for DocumentsDB archives where the indexes table may not exist.

  • Introduces isMissingCollection (using DatabaseNotFoundException subclass check + strcasecmp) and applies it in listTables, listColumns, listIndexes, listRows, and countResources to return []/0 instead of throwing.
  • Adds four focused regression tests covering the missing-collection-table and missing-indexes-table report scenarios as well as direct listIndexes/listRows calls.

Confidence Score: 4/5

Safe to merge for the reporting path; the silent-empty behaviour in listColumns and listIndexes during live migration (not just reporting) is the one area worth watching.

The fix is narrowly scoped and correctly typed — it only intercepts DatabaseNotFoundException with an exact case-insensitive message match, so unrelated errors still propagate. The previously raised concern about listRows silently returning [] during live migration applies equally to listColumns (missing attributes = migrated table has no columns) and listIndexes (missing indexes = migrated table has no indexes), both of which also received the silent-empty treatment in this PR. Those paths aren't exercised during reporting, so the archive-pending bug is fixed, but the same masking risk exists on the migration path.

src/Migration/Sources/Appwrite/Reader/Database.php — specifically the listColumns and listIndexes silent-empty paths when called outside the report context.

Important Files Changed

Filename Overview
src/Migration/Sources/Appwrite/Reader/Database.php Adds isMissingCollection helper (using DatabaseNotFoundException subclass + strcasecmp) and catches it in five places to return empty results/zero counts when a split-DB metadata collection is absent. The countResources re-throw path preserves pre-existing behavior. The same silent-empty concern previously raised for listRows applies equally to listColumns and listIndexes.
tests/Migration/Unit/Sources/AppwriteDatabaseReaderTest.php Adds four regression tests covering: missing collection table in report (returns zero counts), missing indexes table in report (returns zero index count), listIndexes returning empty on missing table, and listRows returning empty on missing table. Tests are well-structured and correctly exercise the new guard.

Reviews (3): Last reviewed commit: "fix: handle empty split database metadat..." | Re-trigger Greptile

Comment thread src/Migration/Sources/Appwrite/Reader/Database.php
@abnegate abnegate force-pushed the fix/empty-split-database-report branch from 2d7ec53 to 312dfe2 Compare June 19, 2026 11:30
@abnegate abnegate force-pushed the fix/empty-split-database-report branch from 312dfe2 to b5100cd Compare June 19, 2026 11:34
@abnegate abnegate enabled auto-merge (squash) June 19, 2026 11:38
@abnegate abnegate requested a review from Meldiron June 19, 2026 11:39
@abnegate abnegate closed this Jun 19, 2026
auto-merge was automatically disabled June 19, 2026 14:08

Pull request was closed

@abnegate abnegate deleted the fix/empty-split-database-report branch June 19, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants