Skip to content

OUT-4043: file-map insert conflict + concurrent-insert race - #129

Open
SandipBajracharya wants to merge 2 commits into
OUT-4041from
OUT-4043
Open

OUT-4043: file-map insert conflict + concurrent-insert race#129
SandipBajracharya wants to merge 2 commits into
OUT-4041from
OUT-4043

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

What

Direct-DB integration tests for MapFilesService.insertFileMap / insertCreatePending against Testcontainers Postgres — covering the behaviors where the database itself is the risk (OUT-4043).

test/flows/file-map-insert.integration.test.ts (12 tests):

insertFileMap

  • inserts a new row and returns it
  • populates the GENERATED item_path_lower column
  • returns null on a partial-unique path conflict (case-insensitive via item_path_lower)
  • lets exactly one row win a concurrent same-path insert race
  • frees the path for a new insert once the existing row is soft-deleted

insertCreatePending

  • inserts a create-pending placeholder row and returns it
  • returns null when a live row already exists at the path
  • updates dbxFileId on conflict for an ASSEMBLY create — null → value (NULL-safe IS DISTINCT FROM)
  • updates dbxFileId on conflict when it changes from one non-null id to another
  • skips the write when the id is unchanged (asserts updatedAt untouched)
  • leaves dbxFileId untouched when the target is DROPBOX
  • leaves dbxFileId untouched when the new dbxFileId is null

Why

Part of the DB-integration test suite (parent OUT-4042). These behaviors — partial-unique indexes, the generated column, concurrent-insert serialization, and IS DISTINCT FROM null semantics — are real Postgres behaviors that mocks can't reproduce, so they run against a real container DB.

Verification

  • pnpm test:integration test/flows/file-map-insert.integration.test.ts → 12/12 pass
  • pnpm lint clean · pnpm typecheck clean

Notes

Base is OUT-4041 (stacked). Reviewed by fullstack-code-reviewer — no correctness issues; its two actionable items (added the non-null→non-null update case, renamed "tombstone"→"placeholder") are applied.

🤖 Generated with Claude Code

… tests

Direct-DB integration tests for MapFilesService.insertFileMap /
insertCreatePending against Testcontainers Postgres: null on partial-unique
path conflict, the concurrent same-path insert race (exactly one row wins),
the generated item_path_lower column, and the dbxFileId update on conflict
(IS DISTINCT FROM, null-safe).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@linear-code

linear-code Bot commented Aug 14, 2026

Copy link
Copy Markdown

OUT-4043

@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dropbox-integration Ready Ready Preview Aug 14, 2026 8:39am

Request Review

@SandipBajracharya SandipBajracharya changed the title test(OUT-4043): file-map insert conflict + concurrent-insert race OUT-4043: file-map insert conflict + concurrent-insert race Aug 14, 2026
@greptile-apps

greptile-apps Bot commented Aug 14, 2026

Copy link
Copy Markdown

Greptile Summary

Adds direct-Postgres integration coverage for file-map insertion and create-pending conflict behavior.

  • Verifies generated lowercase paths, partial-unique conflicts, concurrent insertion, and soft-delete path reuse.
  • Covers conditional dbxFileId updates, including the case-variant conflict scenario requested in the previous review.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
test/flows/file-map-insert.integration.test.ts Adds comprehensive database integration tests, including a case-variant conflict test that resolves the previous review concern.

Reviews (2): Last reviewed commit: "test(OUT-4043): cover case-variant path ..." | Re-trigger Greptile

Comment thread test/flows/file-map-insert.integration.test.ts
Greptile P2: the conflict-update cases used identical casing, so a
case-sensitive regression in the update's lower(itemPath)=lower(payload)
lookup would leave dbxFileId stale for case-variant paths undetected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@SandipBajracharya

Copy link
Copy Markdown
Collaborator Author

@greptileai review again

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.

1 participant