Skip to content

Fixed sample CSV file generation#16261

Merged
charlesBochet merged 1 commit intomainfrom
fix/import-csv
Dec 2, 2025
Merged

Fixed sample CSV file generation#16261
charlesBochet merged 1 commit intomainfrom
fix/import-csv

Conversation

@lucasbordeau
Copy link
Copy Markdown
Contributor

This PR fixes a bug that created a deletedAt column in sample CSV file generated for import, that when used afterwards for import, would create soft deleted records, which gives the impression that the CSV import does not work.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Dec 2, 2025

Greptile Overview

Greptile Summary

This PR fixes a bug where the deletedAt field was included in sample CSV files generated for import. When users downloaded a sample CSV and imported it with data, the deletedAt column would cause records to be soft-deleted upon creation, making them invisible in the UI and giving the false impression that the import failed.

Changes:

  • Added fieldMetadataItem.name !== 'deletedAt' filter in spreadsheetImportFilterAvailableFieldMetadataItems to exclude the deletedAt field from available import fields
  • This matches the existing pattern for excluding createdAt and updatedAt system fields

Impact:

  • CSV sample files will no longer include a deletedAt column
  • Imported records will be created as active records instead of soft-deleted ones
  • Fixes the user experience issue where CSV imports appeared to fail

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Simple, focused fix that adds a single line to exclude deletedAt from import fields. The change follows the existing pattern for system fields (createdAt, updatedAt), directly addresses the reported bug, and has no side effects. The fix is used in both sample CSV generation and actual import flows.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-front/src/modules/object-record/spreadsheet-import/utils/spreadsheetImportFilterAvailableFieldMetadataItems.ts 5/5 Added deletedAt field exclusion to prevent soft-deleted records in CSV imports. Simple, focused fix with no issues.

Sequence Diagram

sequenceDiagram
    participant User
    participant UploadStep
    participant useDownloadFakeRecords
    participant FilterUtil as spreadsheetImportFilterAvailableFieldMetadataItems
    participant CSV as CSV File
    participant ImportDialog
    participant BatchCreate

    Note over User,BatchCreate: Sample CSV Generation Flow
    User->>UploadStep: Click "Download Sample"
    UploadStep->>useDownloadFakeRecords: downloadSample()
    useDownloadFakeRecords->>FilterUtil: Filter updatableFields
    Note over FilterUtil: Excludes: createdAt, updatedAt, deletedAt
    FilterUtil-->>useDownloadFakeRecords: Filtered field list
    useDownloadFakeRecords->>useDownloadFakeRecords: buildTableWithFakeRecords()
    useDownloadFakeRecords->>CSV: Generate CSV with headers & sample data
    CSV-->>User: Download sample.csv

    Note over User,BatchCreate: CSV Import Flow
    User->>User: Fill in CSV with data
    User->>ImportDialog: Upload filled CSV
    ImportDialog->>FilterUtil: Filter updatableFields
    Note over FilterUtil: Without fix: deletedAt included → soft-deleted records
    Note over FilterUtil: With fix: deletedAt excluded → active records
    FilterUtil-->>ImportDialog: Filtered field list
    ImportDialog->>BatchCreate: Create records
    BatchCreate-->>User: Records imported successfully
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps 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 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 2, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:4670

This environment will automatically shut down when the PR is closed or after 5 hours.

@charlesBochet charlesBochet merged commit bf818b7 into main Dec 2, 2025
65 checks passed
@charlesBochet charlesBochet deleted the fix/import-csv branch December 2, 2025 15:32
@twenty-eng-sync
Copy link
Copy Markdown

Hey @lucasbordeau! After you've done the QA of your Pull Request, you can mark it as done here. Thank you!

NotYen pushed a commit to NotYen/twenty-ym that referenced this pull request Dec 4, 2025
This PR fixes a bug that created a deletedAt column in sample CSV file
generated for import, that when used afterwards for import, would create
soft deleted records, which gives the impression that the CSV import
does not work.
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