Skip to content

Conversation

@tonychang04
Copy link

@tonychang04 tonychang04 commented Jan 11, 2026

Summary

Brief description of what this PR does and why.

Add InsForge backend-as-a-service integration as a new tool block in Sim Studio. This enables users to connect to their InsForge backend and perform:

  • Database operations: Query, Get Row, Insert, Update, Delete, Upsert (via PostgREST)
  • Storage operations: Upload, Download, List, Delete files
  • Serverless functions: Invoke edge functions with configurable HTTP methods
  • AI capabilities: Chat completions, Image generation
    Fixes #(issue)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

How has this been tested? What should reviewers focus on?
Screenshot 2026-01-11 at 16 05 16

Focus on the funcionalities

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)

Screenshots/Videos

tonychang04 and others added 4 commits January 10, 2026 20:40
Add InsForge block with 14 tools supporting:
- Database operations: query, get_row, insert, update, delete, upsert
- Storage management: upload, download, list, delete files
- Serverless functions: invoke
- AI capabilities: chat completion, vision, image generation

Includes block definition, tool implementations, icon, registry
updates, and documentation.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Updated all InsForge tool API endpoints to match the actual backend routes:
- Database: /api/database/:tableName (was /rest/v1/:tableName)
- Storage: /api/storage/buckets/:bucket/objects/:key
- Functions: /functions/:slug
- AI Chat: /api/ai/chat/completion
- AI Image: /api/ai/image/generation

Also updated storage_delete to use single file deletion instead of bulk
delete to match InsForge API design.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The InsForge backend routes data queries through /api/database/records/:tableName,
not /api/database/:tableName. Updated all database tools accordingly.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@vercel
Copy link

vercel bot commented Jan 11, 2026

@tonychang04 is attempting to deploy a commit to the Sim Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 11, 2026

Greptile Overview

Greptile Summary

This PR adds comprehensive InsForge backend-as-a-service integration to Sim, providing 14 new tools across database operations, storage management, serverless functions, and AI capabilities. The implementation follows established patterns from similar integrations (like Supabase) and includes documentation.

Key Changes

Database Operations (6 tools): Query, get row, insert, update, delete, and upsert operations using PostgREST API syntax.

Storage Management (4 tools): File upload, download, list, and delete operations for InsForge storage buckets.

AI Capabilities (3 tools): Chat completion, vision analysis, and image generation using OpenAI-compatible APIs.

Serverless Functions (1 tool): Function invocation capability for custom backend logic.

Critical Issues Found

1. Parameter Mismatch in Storage Delete (BLOCKS FUNCTIONALITY)

The block configuration uses paths (plural array) on line 231 of insforge.ts, but the tool expects path (singular string). This mismatch will cause storage delete operations to fail at runtime. The documentation also confirms it should be singular path.

2. Missing Method Parameter Support

The documentation specifies that the invoke function should accept a method parameter (GET, POST, PUT, DELETE), but the implementation hardcodes POST. Either implement the parameter or update the docs.

3. Missing URL Encoding Throughout

All database operations (query, insert, update, delete, upsert, get_row) directly interpolate table names into URLs without encodeURIComponent. Similarly, storage operations don't encode bucket/path parameters, and invoke doesn't encode function names. This will cause failures when names contain special characters like spaces, unicode, or URL-unsafe characters.

Architecture Notes

The integration follows the established block/tool pattern:

  • Block config (apps/sim/blocks/blocks/insforge.ts) handles UI and parameter transformation
  • Individual tool files handle API requests and response transformation
  • Central registry files register all tools and blocks
  • Type definitions in dedicated types.ts file

The implementation correctly uses the AuthMode.ApiKey pattern and includes proper error handling in most tools. The AI tools correctly format multi-part requests for vision, and storage_list is the only tool that properly uses URL encoding.

Confidence Score: 2/5

  • This PR has critical bugs that will cause runtime failures and should not be merged without fixes
  • Score reflects the critical parameter mismatch bug (paths vs path) that will cause storage delete to fail completely, combined with missing method parameter support and widespread lack of URL encoding that will cause failures with special characters. While the overall architecture is sound and most implementations are clean, these are fundamental issues that will break user workflows.
  • Pay critical attention to apps/sim/blocks/blocks/insforge.ts (parameter mismatch bug), apps/sim/tools/insforge/invoke.ts (missing method support), and all database/storage tools for missing URL encoding

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/blocks/blocks/insforge.ts 2/5 Block configuration with critical bugs: paths/path mismatch for storage_delete will cause runtime failures, and unused parsing logic for paths parameter
apps/sim/tools/insforge/invoke.ts 3/5 Invoke function tool with missing method parameter support (documented but not implemented), and missing URL encoding for function names
apps/sim/tools/insforge/storage_delete.ts 3/5 Storage delete implementation missing URL encoding for bucket and path parameters, will fail with special characters
apps/sim/tools/insforge/storage_upload.ts 3/5 Storage upload tool missing URL encoding for bucket/path, body format wraps content in object which may not match API expectations
apps/sim/tools/insforge/storage_download.ts 3/5 Storage download missing URL encoding for bucket and path, otherwise implementation looks solid with proper error handling
apps/sim/tools/insforge/query.ts 3/5 Database query tool missing URL encoding for table name, otherwise clean implementation with good order handling
apps/sim/tools/insforge/insert.ts 3/5 Insert tool missing URL encoding for table name, proper data handling for arrays and objects
apps/sim/tools/insforge/update.ts 3/5 Update tool missing URL encoding for table name, otherwise standard implementation
apps/sim/tools/insforge/delete.ts 3/5 Delete tool missing URL encoding for table name, includes good safety check requiring filter parameter
apps/sim/tools/insforge/upsert.ts 3/5 Upsert tool missing URL encoding for table name, correct merge-duplicates preference header

Sequence Diagram

sequenceDiagram
    participant User
    participant SimUI as Sim UI
    participant Block as InsForge Block
    participant Tool as InsForge Tool
    participant API as InsForge API

    User->>SimUI: Configure InsForge operation
    SimUI->>Block: User provides baseUrl, apiKey, operation params
    
    alt Database Operations
        Block->>Block: Parse data/filter/orderBy params
        Block->>Tool: Call insforge_query/insert/update/delete
        Tool->>Tool: Build URL with table name (missing encoding)
        Tool->>API: GET/POST/PATCH/DELETE /api/database/records/{table}
        API-->>Tool: Return database records
        Tool-->>Block: Transform response with results array
    end
    
    alt Storage Operations
        Block->>Block: Parse paths/fileContent params
        Block->>Tool: Call insforge_storage_upload/download/delete
        Tool->>Tool: Build URL with bucket/path (missing encoding)
        Tool->>API: POST/GET/DELETE /api/storage/buckets/{bucket}/objects/{path}
        API-->>Tool: Return storage operation result
        Tool-->>Block: Transform response
    end
    
    alt AI Operations
        Block->>Block: Parse messages/prompt params
        Block->>Tool: Call insforge_completion/vision/image_generation
        Tool->>Tool: Build request body with AI parameters
        Tool->>API: POST /api/ai/chat/completion or /api/ai/image/generation
        API-->>Tool: Return AI-generated content
        Tool-->>Block: Transform response with content/images
    end
    
    alt Function Invocation
        Block->>Block: Parse body params
        Block->>Tool: Call insforge_invoke
        Tool->>Tool: Build URL (hardcoded POST method)
        Tool->>API: POST /functions/{functionName}
        API-->>Tool: Return function result
        Tool-->>Block: Transform response
    end
    
    Block-->>SimUI: Return operation output
    SimUI-->>User: Display results
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.

13 files reviewed, 13 comments

Edit Code Review Agent Settings | Greptile

tonychang04 and others added 6 commits January 11, 2026 15:58
Block config was using 'paths' (array) but tool expects 'path' (string).

Co-Authored-By: Claude Opus 4.5 <[email protected]>
The storage_delete tool uses singular 'path', not 'paths' array.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Supports GET, POST, PUT, DELETE (default: POST) as documented.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use encodeURIComponent to handle special characters in table names.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use encodeURIComponent to handle special characters.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
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.

1 participant