Skip to content

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Dec 4, 2025

User description

Benchmark PR getsentry#102314

Type: Corrupted (contains bugs)

Original PR Title: feat(search-bar): Add conditionals section to filter key dropdown
Original PR Description: This PR adds in a new Conditionals section that contains AND and OR. We conditionally render this section, once the user has moved off of the first item as you can not start a filter with a conditional.

Ticket: EXP-562

Example:

Screenshot 2025-10-29 at 07 33 46 **Original PR URL**: https://github.com/getsentry/pull/102314

PR Type

Enhancement


Description

  • Add logical operators (AND, OR, parentheses) section to filter key dropdown menu

  • Conditionally render logic operators only when not on first filter item

  • Rename "boolean" terminology to "logic" throughout codebase

  • Add disallowLogicalOperators prop to control logic operators visibility

  • Update spacing values to use theme tokens instead of hardcoded space function


Diagram Walkthrough

flowchart LR
  A["Filter Key Dropdown"] -->|"Add Logic Category"| B["Logic Operators Section"]
  B -->|"AND, OR, Parentheses"| C["Conditional Filters"]
  D["disallowLogicalOperators Prop"] -->|"Controls Visibility"| B
  E["First Item Check"] -->|"Hide on First"| B
  F["Feature Flag"] -->|"Enables Feature"| B
Loading

File Walkthrough

Relevant files
Enhancement
6 files
context.tsx
Export disallowLogicalOperators from context                         
+2/-0     
index.tsx
Update spacing to use theme tokens                                             
+15/-11 
types.tsx
Add LogicFilterItem type definition                                           
+9/-2     
useFilterKeyListBox.tsx
Conditionally add logic operators to filter menu                 
+69/-6   
utils.tsx
Create logic filter item factory function                               
+19/-0   
freeText.tsx
Handle logic filter selection in free text input                 
+13/-0   
Refactoring
2 files
useQueryBuilderState.tsx
Rename boolean operator to logic operator                               
+7/-7     
boolean.tsx
Rename boolean to logic operator terminology                         
+5/-5     
Tests
1 files
index.spec.tsx
Add tests for logic operators section                                       
+55/-8   

@qodo-code-review
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Missing Auditing: The new logic-operator insertion path adds/modifies query state without any visible audit
logging of this critical user action, and the diff provides no evidence that such actions
are logged elsewhere.

Referred Code
  dispatch({
    type: 'UPDATE_QUERY',
    query: option.value,
    focusOverride: {itemKey: 'end'},
  });
  return;
}

if (option.type === 'logic-filter') {
  dispatch({
    type: 'UPDATE_FREE_TEXT_ON_SELECT',
    tokens: [token],
    text: option.value,
    shouldCommitQuery: false,
    focusOverride: calculateNextFocusForInsertedToken(item),
  });
  resetInputValue();
  return;
}

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Missing Edge Cases: Handling for selecting a 'logic-filter' directly updates query state without
visible validation for edge cases (e.g., first-item disallow, surrounding token context),
relying on external logic not shown in the diff.

Referred Code
  dispatch({
    type: 'UPDATE_QUERY',
    query: option.value,
    focusOverride: {itemKey: 'end'},
  });
  return;
}

if (option.type === 'logic-filter') {
  dispatch({
    type: 'UPDATE_FREE_TEXT_ON_SELECT',
    tokens: [token],
    text: option.value,
    shouldCommitQuery: false,
    focusOverride: calculateNextFocusForInsertedToken(item),
  });
  resetInputValue();
  return;
}

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Input Validation: New logic adds selectable logic tokens and dispatches updates based on user input without
explicit sanitization/validation shown for these inputs, which may rely on parsing
safeguards not visible in the diff.

Referred Code
    ...makeRecentSearchQueryItems({
      recentSearches,
      filterKeys,
      getFieldDefinition,
    }),
  ];
}

if (
  disallowLogicalOperators &&
  selectedSection === LOGIC_CATEGORY_VALUE &&
  hasConditionalsInCombobox
) {
  return [...askSeerItem, ...conditionalFilterItems];
}

Learn more about managing compliance generic rules or creating your own custom rules

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Fix inverted conditional logic check

Invert the disallowLogicalOperators check to correctly hide the 'Logic' category
when logical operators are disallowed.

static/app/components/searchQueryBuilder/tokens/filterKeyListBox/useFilterKeyListBox.tsx [166-168]

-if (disallowLogicalOperators && !isFirstItem && hasConditionalsInCombobox) {
+if (!disallowLogicalOperators && !isFirstItem && hasConditionalsInCombobox) {
   recentSearchesSections.push(LOGIC_CATEGORY);
 }
  • Apply / Chat
Suggestion importance[1-10]: 9

__

Why: The suggestion correctly identifies a bug where the disallowLogicalOperators flag has the opposite of its intended effect, causing the 'Logic' category to appear when it should be hidden. This is a critical logic error that breaks the functionality of the new prop.

High
  • More

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants