Skip to content

Rollback standard id removal on relation object creation#16177

Merged
charlesBochet merged 1 commit intomainfrom
rollback-standard-id-change
Nov 28, 2025
Merged

Rollback standard id removal on relation object creation#16177
charlesBochet merged 1 commit intomainfrom
rollback-standard-id-change

Conversation

@charlesBochet
Copy link
Copy Markdown
Member

No description provided.

Copy link
Copy Markdown
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Nov 28, 2025

Greptile Overview

Greptile Summary

This PR rolls back a previous change that incorrectly set standardId: null for relation fields on custom objects. The rollback restores the proper lookup of standard IDs from CUSTOM_OBJECT_STANDARD_FIELD_IDS based on the target object's plural name.

Key changes:

  • Re-imports CUSTOM_OBJECT_STANDARD_FIELD_IDS constant
  • Restores standardId lookup logic in generateSourceFlatFieldMetadata
  • Adds validation that throws an exception if the standard ID is not found
  • Changes standardId from null to the properly looked-up UUID value

How it works:
The function creates default relation fields for custom objects (like timelineActivities, favorites, attachments, noteTargets, taskTargets). Each of these relation fields needs a standardId that maps to predefined UUIDs in CUSTOM_OBJECT_STANDARD_FIELD_IDS. The previous change incorrectly removed this lookup, causing relation fields to be created without proper standard IDs.

Confidence Score: 4/5

  • This PR is safe to merge - it's a straightforward rollback that restores critical metadata functionality
  • The rollback correctly restores the standardId lookup logic that was incorrectly removed. The implementation properly validates that standard IDs exist before using them (throwing an exception if not found). However, there's a minor concern: the lookup uses targetFlatObjectMetadata.namePlural as the key, which requires exact naming alignment between object plural names and CUSTOM_OBJECT_STANDARD_FIELD_IDS keys. This works for the five standard relations (timelineActivities, favorites, attachments, noteTargets, taskTargets) but the error handling would catch any mismatches.
  • No files require special attention - this is a clean rollback of a previous change

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-server/src/engine/metadata-modules/object-metadata/utils/build-default-relation-flat-field-metadatas-for-custom-object.util.ts 4/5 Rollback that restores standardId lookup from CUSTOM_OBJECT_STANDARD_FIELD_IDS for relation fields on custom objects, fixing a regression where standardId was set to null

Sequence Diagram

sequenceDiagram
    participant Builder as buildDefaultRelationFlatFieldMetadatasForCustomObject
    participant GenSource as generateSourceFlatFieldMetadata
    participant GenTarget as generateTargetFlatFieldMetadata
    participant Constants as CUSTOM_OBJECT_STANDARD_FIELD_IDS
    
    Builder->>Builder: Loop through DEFAULT_RELATIONS_OBJECTS_STANDARD_IDS
    Note over Builder: For each: timelineActivity, favorite,<br/>attachment, noteTarget, taskTarget
    
    Builder->>GenSource: generateSourceFlatFieldMetadata(sourceFlatObjectMetadata, targetFlatObjectMetadata)
    GenSource->>Constants: Lookup standardId by targetFlatObjectMetadata.namePlural
    Note over GenSource,Constants: Maps singular object names to plural field names:<br/>timelineActivity → timelineActivities<br/>favorite → favorites<br/>attachment → attachments<br/>noteTarget → noteTargets<br/>taskTarget → taskTargets
    
    alt standardId found
        Constants-->>GenSource: Return standardId (UUID)
        GenSource->>GenSource: Create relation field with standardId
    else standardId not found
        GenSource->>GenSource: Throw ObjectMetadataException
    end
    
    GenSource-->>Builder: Return sourceFlatFieldMetadata
    
    Builder->>GenTarget: generateTargetFlatFieldMetadata(sourceFlatFieldMetadata, targetFlatObjectMetadata)
    GenTarget->>GenTarget: Create deterministic UUID using objectId + customStandardFieldId
    GenTarget-->>Builder: Return targetFlatFieldMetadata
    
    Builder->>Builder: Accumulate source and target field metadatas
    Builder-->>Builder: Return complete field metadata arrays
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

@charlesBochet charlesBochet merged commit 9387680 into main Nov 28, 2025
53 checks passed
@charlesBochet charlesBochet deleted the rollback-standard-id-change branch November 28, 2025 14:11
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Preview Environment Ready!

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

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

NotYen pushed a commit to NotYen/twenty-ym that referenced this pull request Dec 4, 2025
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