Skip to content

Conversation

@Dakuan
Copy link
Contributor

@Dakuan Dakuan commented Jan 7, 2026

Summary by cubic

Rescues tombstoned prod table docs during publish by restoring table metadata when prod has live rows, preventing broken tables and data loss.

  • Bug Fixes
    • Before replication, detect prod tables with live rows but missing/tombstoned table docs and restore them from dev (preserving prod _rev when present).
    • Paginated scan of row docs to find affected table IDs, honoring tablesToSeed and skipping USER_METADATA; added a test confirming the table doc is revived and both dev/prod rows remain.

Written for commit b9345a2. Summary will update on new commits.

@github-actions github-actions bot added the size/m label Jan 7, 2026
@Dakuan
Copy link
Contributor Author

Dakuan commented Jan 7, 2026

@cubic-dev-ai

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Jan 7, 2026

@cubic-dev-ai

@Dakuan I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@adrinr adrinr force-pushed the fix/rescue-tombstoned-tables branch from c90647a to 2224c5c Compare January 8, 2026 21:42
Copy link
Member

@adrinr adrinr left a comment

Choose a reason for hiding this comment

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

This works fine, I managed to reproduce he issue locally. I am just worried about the performance of it. Instead of relying on the rows, that can be millions, we should probably compare the list of tables in dev vs the ones in prod. Otherwise publishing workspaces with a lot of rows will cause delays

@Dakuan
Copy link
Contributor Author

Dakuan commented Jan 9, 2026

@cubic-dev-ai

@cubic-dev-ai
Copy link
Contributor

cubic-dev-ai bot commented Jan 9, 2026

@cubic-dev-ai

@Dakuan I have started the AI code review. It will take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Confidence score: 3/5

  • The unreachable if (prodTable._deleted) branch in packages/server/src/api/controllers/deploy/index.ts means the expected revision for tombstoned tables is never captured, so deploy logic can’t handle deleted documents correctly.
  • This gap could surface as failed or inconsistent deploys when production documents were previously deleted, giving the change a meaningful regression risk.
  • Pay close attention to packages/server/src/api/controllers/deploy/index.ts - confirm tombstoned documents are handled without relying on an unreachable _deleted branch.
Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/server/src/api/controllers/deploy/index.ts">

<violation number="1" location="packages/server/src/api/controllers/deploy/index.ts:306">
P1: The `if (prodTable._deleted)` branch is unreachable. CouchDB returns 404 for tombstoned documents, so `tryGet` returns `undefined` rather than a doc with `_deleted: true`. The `prodRev` will never be captured for tombstoned tables, which may cause conflict errors when putting the rescued doc. Consider using `allDocs` with `keys: [tableId]` which can return deleted doc metadata, or fetch with explicit revision.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

targets.push({ tableId })
continue
}
if (prodTable._deleted) {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 9, 2026

Choose a reason for hiding this comment

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

P1: The if (prodTable._deleted) branch is unreachable. CouchDB returns 404 for tombstoned documents, so tryGet returns undefined rather than a doc with _deleted: true. The prodRev will never be captured for tombstoned tables, which may cause conflict errors when putting the rescued doc. Consider using allDocs with keys: [tableId] which can return deleted doc metadata, or fetch with explicit revision.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/server/src/api/controllers/deploy/index.ts, line 306:

<comment>The `if (prodTable._deleted)` branch is unreachable. CouchDB returns 404 for tombstoned documents, so `tryGet` returns `undefined` rather than a doc with `_deleted: true`. The `prodRev` will never be captured for tombstoned tables, which may cause conflict errors when putting the rescued doc. Consider using `allDocs` with `keys: [tableId]` which can return deleted doc metadata, or fetch with explicit revision.</comment>

<file context>
@@ -185,6 +187,168 @@ async function applyPendingColumnRenames(
+          targets.push({ tableId })
+          continue
+        }
+        if (prodTable._deleted) {
+          targets.push({ tableId, prodRev: prodTable._rev })
+        }
</file context>
Fix with Cubic

@github-actions github-actions bot added the stale label Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants