Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • fixed zendesk tools,
  • kb upload failure for md files since the browser sends an empty content type, so we now derive it from the extension if content type is missing both client-side and server-side
  • add new wordpress route to align with the other download/upload tools
  • fix icons in tag dropdown to display actual icons

Type of Change

  • Bug fix

Testing

tested manually

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 Dec 11, 2025

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

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Dec 11, 2025 4:39am

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 11, 2025

Greptile Overview

Greptile Summary

This PR fixes multiple issues across Zendesk tools, knowledge base uploads, and WordPress integrations, while improving type definitions throughout.

Key Changes

  • Knowledge Base MD Upload Fix: Browsers send empty content types for .md files, causing upload failures. Fixed by implementing getFileContentType helper that falls back to extension-based MIME type lookup when file.type is empty. Both client-side (use-knowledge-upload.ts) and server-side (validation.ts) now handle empty MIME types gracefully.

  • Zendesk Tool Output Typing: Flattened output structure across all 26 Zendesk tools by removing redundant nested success and output wrappers. Updated block config to define operation-specific outputs (ticket, tickets, user, users, organization, organizations, results, count, jobStatus, deleted, paging, metadata) instead of generic success/output fields.

  • WordPress Upload Route: Added /api/tools/wordpress/upload route to align with other tool patterns (download/upload architecture). Tool now uses file type instead of string for better type safety, and block UI provides both file-upload component and variable reference modes.

  • Tag Dropdown Icons: Fixed icon display by supporting React component icons (RepeatIcon, SplitIcon) in addition to letter-based icons. Now uses actual block icons when available, falling back to special icons for loop/parallel blocks.

  • YouTube Tool Cleanup: Removed related_videos tool and its references.

Issues Found

  • Code duplication: getMimeType function in apps/sim/app/api/tools/wordpress/upload/route.ts duplicates existing getMimeTypeFromExtension from @/lib/uploads/utils/file-utils

Confidence Score: 4/5

  • This PR is safe to merge with minor code duplication that should be addressed
  • The changes are well-structured and address real bugs (MD file uploads, Zendesk typing). The implementations are sound with proper error handling and logging. Score reduced by 1 point due to code duplication in the WordPress route that should use existing utilities.
  • apps/sim/app/api/tools/wordpress/upload/route.ts has code duplication that should use existing utilities

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/lib/uploads/utils/validation.ts 5/5 Added fallback for empty MIME types by returning early when baseMimeType is empty, allowing extension-based validation
apps/sim/app/workspace/[workspaceId]/knowledge/hooks/use-knowledge-upload.ts 5/5 Implemented getFileContentType helper to fallback to extension-based MIME type lookup when browser provides empty type
apps/sim/tools/zendesk/create_ticket.ts 5/5 Flattened outputs structure, removing redundant nested success and output wrapper
apps/sim/blocks/blocks/zendesk.ts 5/5 Replaced generic outputs with detailed, operation-specific output definitions for all Zendesk operations
apps/sim/app/api/tools/wordpress/upload/route.ts 4/5 New API route for WordPress media uploads using file storage system; includes duplicate getMimeType implementation
apps/sim/tools/wordpress/upload_media.ts 5/5 Refactored to use custom API route instead of direct WordPress API, changed file param from string to file type
apps/sim/blocks/blocks/wordpress.ts 5/5 Added file-upload UI component with basic/advanced modes and support for both direct uploads and variable references
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx 5/5 Enhanced TagIcon to support React component icons (RepeatIcon, SplitIcon) in addition to letter icons, using actual block icons

Sequence Diagram

sequenceDiagram
    participant User
    participant Browser
    participant KBUploadHook as Knowledge Upload Hook
    participant ValidationUtils as Validation Utils
    participant FileUtils as File Utils
    participant S3 as S3 Storage

    Note over User,S3: MD File Upload Flow (Fixed)
    
    User->>Browser: Select .md file
    Browser->>KBUploadHook: File object (empty type)
    KBUploadHook->>KBUploadHook: getFileContentType(file)
    alt file.type is empty
        KBUploadHook->>FileUtils: getFileExtension(filename)
        FileUtils-->>KBUploadHook: "md"
        KBUploadHook->>FileUtils: getMimeTypeFromExtension("md")
        FileUtils-->>KBUploadHook: "text/markdown"
    else file.type exists
        KBUploadHook->>KBUploadHook: Use file.type
    end
    
    KBUploadHook->>ValidationUtils: validateFileType(filename, mimeType)
    ValidationUtils->>ValidationUtils: Check if baseMimeType is empty
    alt baseMimeType is empty
        ValidationUtils-->>KBUploadHook: null (allow)
    else baseMimeType exists
        ValidationUtils->>ValidationUtils: Validate against allowed types
        ValidationUtils-->>KBUploadHook: null or error
    end
    
    KBUploadHook->>S3: Upload with derived MIME type
    S3-->>KBUploadHook: Success
    KBUploadHook-->>User: File uploaded

    Note over User,S3: WordPress Upload Flow (New Route)
    
    User->>Browser: Select media file
    Browser->>WordPressTool: File via tool
    WordPressTool->>APIRoute: POST /api/tools/wordpress/upload
    APIRoute->>APIRoute: processSingleFileToUserFile
    APIRoute->>APIRoute: downloadFileFromStorage
    APIRoute->>APIRoute: getMimeType (extension-based)
    APIRoute->>WordPress: FormData with file
    WordPress-->>APIRoute: Media object
    APIRoute-->>WordPressTool: Success response
    WordPressTool-->>User: Media uploaded
Loading

Copy link
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.

51 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 6c99c84 into staging Dec 11, 2025
9 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/tools branch December 11, 2025 04:42
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