twenty icon indicating copy to clipboard operation
twenty copied to clipboard

fix(workflow): UUID filter in "Search Records" action

Open rdelassus opened this issue 3 weeks ago • 2 comments

Summary

  • add a regression test that reproduces the workflow "Search Records → ID is <UUID>" failure (issue #15067 / #15746)
  • adjust turnRecordFilterIntoRecordGqlOperationFilter so UUID filters fall back to the literal value when no recordIdsForUuid context is provided, always emitting an in clause

Testing

  • npx nx test twenty-shared -- --testPathPattern=computeRecordGqlOperationFilter.test.ts --coverage=false
  • Manual: workflow "Search Records" with filter "ID is <UUID>" now returns the correct record

Fixes #15067 Fixes #15746

rdelassus avatar Nov 14 '25 09:11 rdelassus

Greptile Overview

Greptile Summary

Fixes a critical workflow bug where "Search Records" action with filter "ID is {UUID}" was returning all records instead of the single matching record. The fix adds a fallback mechanism in the UUID filter case to use the literal UUID value when no recordIdsForUuid context is provided (workflow scenario), ensuring the filter always emits a proper in clause.

Key changes:

  • Updated turnRecordFilterIntoRecordGqlOperationFilter to check if recordIdsForUuid exists and has length > 0 before using it
  • Falls back to parsing recordFilter.value via arrayOfUuidOrVariableSchema when no context is provided
  • Added regression test that validates the fix for workflow UUID filtering without context

The fix is minimal, targeted, and properly tested. The logic correctly handles both scenarios: when recordIdsForUuid context is provided (existing behavior) and when it's not (new workflow behavior).

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • The fix is minimal, well-targeted, and addresses a specific bug without affecting other functionality. It adds proper fallback logic with validation via the existing arrayOfUuidOrVariableSchema, includes a regression test, and maintains backward compatibility by checking if recordIdsForUuid exists before falling back to the literal value.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/twenty-shared/src/utils/filter/tests/computeRecordGqlOperationFilter.test.ts 5/5 New regression test for UUID filter without recordIdsForUuid context - properly validates fix
packages/twenty-shared/src/utils/filter/turnRecordFilterIntoGqlOperationFilter.ts 5/5 Fixes UUID filter to fallback to literal value when no recordIdsForUuid context provided

Sequence Diagram

sequenceDiagram
    participant WF as Workflow Action<br/>(Search Records)
    participant CF as computeRecordGqlOperationFilter
    participant TRF as turnRecordFilterIntoRecordGqlOperationFilter
    participant VS as arrayOfUuidOrVariableSchema
    participant GQL as GraphQL Query

    WF->>CF: Filter: ID is {UUID}
    Note over WF,CF: recordIdsForUuid = undefined<br/>(no context provided)
    CF->>TRF: recordFilter, fields, filterValueDependencies
    Note over TRF: Case 'UUID'
    alt recordIdsForUuid exists and length > 0
        TRF->>TRF: Use recordIdsForUuid
    else No recordIdsForUuid context
        TRF->>VS: Parse recordFilter.value
        VS-->>TRF: [UUID]
        Note over TRF: NEW FIX: Falls back to<br/>literal UUID value
    end
    TRF-->>CF: {id: {in: [UUID]}}
    CF-->>WF: Complete filter object
    WF->>GQL: Query with proper UUID filter
    GQL-->>WF: Returns single matching record

greptile-apps[bot] avatar Nov 14 '25 09:11 greptile-apps[bot]

Thanks @rdelassus for your contribution! This marks your 1st PR on the repo. You're top 39% of all our contributors 🎉 See contributor page - Share on LinkedIn - Share on Twitter

Contributions

github-actions[bot] avatar Nov 18 '25 10:11 github-actions[bot]