Skip to content

Fix missing metadata version in legacy datasource#16173

Merged
etiennejouan merged 1 commit intomainfrom
c--fix-metadata-version-missing-in-datasource
Nov 28, 2025
Merged

Fix missing metadata version in legacy datasource#16173
etiennejouan merged 1 commit intomainfrom
c--fix-metadata-version-missing-in-datasource

Conversation

@Weiko
Copy link
Copy Markdown
Member

@Weiko Weiko commented Nov 28, 2025

No description provided.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Nov 28, 2025

Greptile Overview

Greptile Summary

Fixed cache inconsistency in getWorkspaceMetadataVersionFromCacheOrFromDB by adding missing setMetadataVersion call after fetching from database.

  • Added await this.workspaceCacheStorageService.setMetadataVersion(workspaceId, workspace.metadataVersion) after DB fetch
  • Ensures cache is populated on first access, preventing repeated DB queries
  • Aligns with identical pattern in workspace-schema.factory.ts:90-93

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change is a straightforward bug fix that adds a missing cache write operation. The fix follows the exact pattern used elsewhere in the codebase (workspace-schema.factory.ts), ensuring consistency. The change has no side effects and only prevents repeated database queries by properly populating the cache.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/engine/twenty-orm/factories/workspace-datasource.factory.ts 5/5 Added missing cache write for metadata version when fetched from DB, ensuring consistency with similar code in workspace-schema.factory.ts

Sequence Diagram

sequenceDiagram
    participant Client
    participant WorkspaceDatasourceFactory
    participant WorkspaceCacheStorageService
    participant WorkspaceRepository
    participant Database

    Client->>WorkspaceDatasourceFactory: create(workspaceId)
    WorkspaceDatasourceFactory->>WorkspaceDatasourceFactory: getWorkspaceMetadataVersionFromCacheOrFromDB(workspaceId)
    WorkspaceDatasourceFactory->>WorkspaceCacheStorageService: getMetadataVersion(workspaceId)
    WorkspaceCacheStorageService-->>WorkspaceDatasourceFactory: undefined (cache miss)
    
    WorkspaceDatasourceFactory->>WorkspaceRepository: findOne({id: workspaceId})
    WorkspaceRepository->>Database: SELECT * FROM workspace WHERE id = ?
    Database-->>WorkspaceRepository: workspace record
    WorkspaceRepository-->>WorkspaceDatasourceFactory: workspace
    
    Note over WorkspaceDatasourceFactory: Fix: Added missing cache write
    WorkspaceDatasourceFactory->>WorkspaceCacheStorageService: setMetadataVersion(workspaceId, workspace.metadataVersion)
    WorkspaceCacheStorageService-->>WorkspaceDatasourceFactory: void
    
    WorkspaceDatasourceFactory-->>Client: workspace.metadataVersion
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

@etiennejouan etiennejouan enabled auto-merge (squash) November 28, 2025 11:50
@etiennejouan etiennejouan merged commit 470888a into main Nov 28, 2025
54 checks passed
@etiennejouan etiennejouan deleted the c--fix-metadata-version-missing-in-datasource branch November 28, 2025 11:54
@twenty-eng-sync
Copy link
Copy Markdown

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

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.

3 participants