Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • Remove title fallback in getCustomTool that could return wrong tool if titles collide
  • Tools should always be looked up by ID, not title

Type of Change

  • Bug fix

Testing

  • All 3,392 tests pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 22, 2026 1:26am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 22, 2026

Greptile Summary

This PR restores title-based lookup in getCustomTool, which was previously removed. The change is necessary because custom tools are referenced as custom_${title} throughout the system, not by database ID.

The implementation combines ID and title matching into a single find() operation with an OR condition, which is more efficient than the previous approach of chaining two separate find() calls. Since titles are unique per workspace (enforced by database constraint custom_tools_workspace_title_unique), this lookup is safe and won't return incorrect tools.

Note: The PR title says "remove unsafe title fallback" but the actual change restores it. The commit message correctly describes this as restoring the title lookup.

Confidence Score: 4/5

  • This PR is safe to merge with one caveat: the PR title is misleading
  • The code change correctly restores necessary title lookup functionality that custom tools require. The implementation is sound, titles are unique per workspace (database constraint), and all tests pass. Score is 4 instead of 5 due to misleading PR title that contradicts the actual change.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/hooks/queries/custom-tools.ts Restored title lookup in getCustomTool by combining ID and title match into single find operation with OR condition

Sequence Diagram

sequenceDiagram
    participant Client as Client Code
    participant Utils as tools/utils.ts
    participant Query as custom-tools.ts
    participant Cache as React Query Cache
    participant DB as Database

    Client->>Utils: getTool("custom_myTool")
    Utils->>Utils: Extract identifier = "myTool"
    Utils->>Query: getCustomTool("myTool")
    Query->>Query: Extract workspaceId from URL
    Query->>Cache: getQueryData(workspaceId)
    
    alt Cache Hit
        Cache-->>Query: Return cached tools[]
        Query->>Query: find(tool => tool.id === "myTool" || tool.title === "myTool")
        Query-->>Utils: Return matching tool
        Utils-->>Client: Return ToolConfig
    else Cache Miss
        Cache-->>Query: Return undefined/empty
        Query-->>Utils: Return undefined
        Utils-->>Client: Return undefined
    end

    Note over Query,DB: Title is unique per workspace<br/>(custom_tools_workspace_title_unique)
Loading

cursor[bot]

This comment was marked as outdated.

Custom tools are referenced by title (custom_${title}), not database ID.
The title fallback is required for client-side tool resolution to work.
@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@waleedlatif1 waleedlatif1 merged commit 5987a6d into staging Jan 22, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/custom-tools-lookup branch January 22, 2026 01:36
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