Skip to content

fix(db): harden workspace file size cutover - #7123

Merged
waleedlatif1 merged 2 commits into
stagingfrom
codex/fix-workspace-file-size-backfill
Aug 26, 2026
Merged

fix(db): harden workspace file size cutover#7123
waleedlatif1 merged 2 commits into
stagingfrom
codex/fix-workspace-file-size-backfill

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Treat database-ordered text cursors as opaque so locale collation cannot abort the bounded backfill
  • Remove implicit legacy size projections and fail closed when canonical size metadata is missing

Type of Change

  • Bug fix

Testing

  • 96 DB tests
  • App and DB typechecks
  • Full lint and strict API validation
  • Migration safety check and locale-aware PostgreSQL reproduction

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 26, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 26, 2026 8:32pm

Request Review

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR completes the workspace-file canonical size cutover and hardens its backfill behavior.

  • Replaces legacy size projections with canonical sizeBytes reads that fail closed when metadata is missing.
  • Makes the bounded backfill treat database-ordered text IDs as opaque cursors.
  • Updates file operations, storage accounting, mocks, and tests for the canonical size contract.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/db/script-migrations/0008_backfill_workspace_file_size_bytes.ts Treats database-ordered text IDs as opaque cursors while retaining bounded, idempotent keyset backfill behavior.
packages/db/script-migrations/0003_backfill_workspace_storage_usage.ts Ensures canonical file sizes are populated before workspace storage usage is reconciled.
packages/db/schema.ts Establishes the canonical workspace-file projection around sizeBytes while retaining the legacy field for migration compatibility.
apps/sim/lib/billing/storage/payer-transfer.ts Uses canonical size metadata for storage transfers and rejects incomplete size data rather than silently misaccounting it.
apps/sim/lib/uploads/contexts/workspace/workspace-file-manager.ts Converts workspace-file lifecycle and accounting paths to the canonical size accessor.
apps/sim/app/api/files/export/[id]/route.ts Uses canonical metadata for export accounting and omits embedded assets whose canonical size cannot be established.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[SQL migration adds size_bytes] --> B[Compatibility trigger synchronizes size columns]
  B --> C[Script migration backfills null size_bytes in bounded batches]
  C --> D[Application queries project canonical workspace-file columns]
  D --> E[getWorkspaceFileSize validates sizeBytes]
  E -->|Valid| F[File operations and storage accounting continue]
  E -->|Missing or invalid| G[Operation fails closed]
Loading

Reviews (2): Last reviewed commit: "fix(files): skip malformed export assets" | Re-trigger Greptile

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 28 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread apps/sim/app/api/files/export/[id]/route.ts Outdated
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Aug 26, 2026

Copy link
Copy Markdown

@cubic review

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

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 28 files

Confidence score: 5/5

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

Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit ea6a6c2 into staging Aug 26, 2026
24 checks passed
@waleedlatif1
waleedlatif1 deleted the codex/fix-workspace-file-size-backfill branch August 26, 2026 20:37
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