Skip to content

Conversation

@lakeesiv
Copy link

@lakeesiv lakeesiv commented Jan 12, 2026

Summary

Adds Tinybird integration with two operations:
Send Events: Stream JSON/NDJSON events to Tinybird Data Sources with compression and acknowledgment options
Query: Execute SQL queries against Tinybird Pipes and Data Sources with support for multiple output formats (JSON, CSV, TSV, etc.)
Includes block configuration, tool implementations, API routes, and a custom icon component.

Type of Change

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

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)

icecrasher321 and others added 25 commits December 18, 2025 16:23
…dioai#2481)

The realtime service network policy was missing the custom egress rules section
that allows configuration of additional egress rules via values.yaml. This caused
the realtime pods to be unable to connect to external databases (e.g., PostgreSQL
on port 5432) when using external database configurations.

The app network policy already had this section, but the realtime network policy
was missing it, creating an inconsistency and preventing the realtime service
from accessing external databases configured via networkPolicy.egress values.

This fix adds the same custom egress rules template section to the realtime
network policy, matching the app network policy behavior and allowing users to
configure database connectivity via values.yaml.
…ext menu (simstudioai#2672)

* feat(logs-context-menu): consolidated logs utils and types, added logs record context menu (simstudioai#2659)

* feat(email): welcome email; improvement(emails): ui/ux (simstudioai#2658)

* feat(email): welcome email; improvement(emails): ui/ux

* improvement(emails): links, accounts, preview

* refactor(emails): file structure and wrapper components

* added envvar for personal emails sent, added isHosted gate

* fixed failing tests, added env mock

* fix: removed comment

---------

Co-authored-by: waleed <[email protected]>

* fix(logging): hitl + trigger dev crash protection (simstudioai#2664)

* hitl gaps

* deal with trigger worker crashes

* cleanup import strcuture

* feat(imap): added support for imap trigger (simstudioai#2663)

* feat(tools): added support for imap trigger

* feat(imap): added parity, tested

* ack PR comments

* final cleanup

* feat(i18n): update translations (simstudioai#2665)

Co-authored-by: waleedlatif1 <[email protected]>

* fix(grain): updated grain trigger to auto-establish trigger (simstudioai#2666)

Co-authored-by: aadamgough <[email protected]>

* feat(admin): routes to manage deployments (simstudioai#2667)

* feat(admin): routes to manage deployments

* fix naming fo deployed by

* feat(time-picker): added timepicker emcn component, added to playground, added searchable prop for dropdown, added more timezones for schedule, updated license and notice date (simstudioai#2668)

* feat(time-picker): added timepicker emcn component, added to playground, added searchable prop for dropdown, added more timezones for schedule, updated license and notice date

* removed unused params, cleaned up redundant utils

* improvement(invite): aligned styling (simstudioai#2669)

* improvement(invite): aligned with rest of app

* fix(invite): error handling

* fix: addressed comments

---------

Co-authored-by: Emir Karabeg <[email protected]>
Co-authored-by: Vikhyath Mondreti <[email protected]>
Co-authored-by: waleedlatif1 <[email protected]>
Co-authored-by: Adam Gough <[email protected]>
Co-authored-by: aadamgough <[email protected]>
…ion, autoconnect improvements, billing fixes
@vercel
Copy link

vercel bot commented Jan 12, 2026

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

A member of the Team first needs to authorize it.

@lakeesiv lakeesiv marked this pull request as ready for review January 12, 2026 20:33
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 12, 2026

Greptile Overview

Greptile Summary

This PR adds Tinybird integration to Sim with two operations: Send Events and Query.

Implementation Overview

The implementation follows the established block/tool pattern used throughout the codebase:

  • Block Configuration (tinybird.ts): Defines the UI with conditional fields for each operation
  • Tool Implementations:
    • events.ts: Streams JSON/NDJSON events with gzip compression support
    • query.ts: Executes SQL queries with multi-format output (JSON, CSV, TSV)
  • Type Definitions (types.ts): Clean TypeScript interfaces
  • Registries: Both block and tool registries properly updated

Architecture

The block uses a dropdown to switch between operations, with conditional fields that show/hide based on the selected operation. The tools.config.params function handles parameter transformation and routing to the appropriate tool.

Strengths

✅ Follows established patterns from similar blocks (PostHog, Sentry)
✅ Good error handling in both tools
✅ Proper content-type detection for multi-format query responses
✅ Compression support for events API
✅ Clean separation of concerns

Issues Found

All issues are style/improvement suggestions - no blocking bugs:

  1. base_url field: Required but no default value provided (most users will use default URL)
  2. Boolean conversion: Inconsistent handling of string case variations ('True' vs 'False')
  3. Data validation: Could add type checking for buffer conversions and response parsing
  4. Error messages: Could truncate very long error responses to prevent log overflow
  5. Response validation: Could add more defensive checks for API response structure

Testing Notes

The PR indicates tests were not added. Reviewers should verify:

  • Both operations work with various data formats
  • Compression works correctly
  • Error cases are handled properly
  • Boolean switch values convert correctly

Confidence Score: 4/5

  • This PR is safe to merge with minor improvements recommended. No critical bugs found.
  • The implementation is solid and follows established patterns. All issues found are style improvements (better error handling, validation, and edge case handling) rather than functional bugs. The code will work correctly for the happy path. Tests are missing, which prevents a score of 5.
  • apps/sim/blocks/blocks/tinybird.ts (add default base_url), apps/sim/tools/tinybird/events.ts (improve data validation), apps/sim/tools/tinybird/query.ts (improve response validation)

Important Files Changed

File Analysis

Filename Score Overview
apps/sim/blocks/blocks/tinybird.ts 4/5 Block configuration for Tinybird integration with two operations (Send Events, Query). Found minor issues with base_url default and boolean conversion consistency.
apps/sim/tools/tinybird/events.ts 4/5 Events API tool implementation with gzip compression support. Good error handling, minor improvements suggested for data validation and response parsing.
apps/sim/tools/tinybird/query.ts 4/5 Query API tool with multi-format support (JSON, CSV, TSV). Well-structured with good content-type detection, suggested improvements for response validation.
apps/sim/tools/tinybird/types.ts 5/5 Clean TypeScript type definitions for Tinybird tools. Well-structured with proper interfaces and union types.

Sequence Diagram

sequenceDiagram
    participant User
    participant TinybirdBlock
    participant ToolRegistry
    participant EventsTool
    participant QueryTool
    participant TinybirdAPI

    Note over User,TinybirdAPI: Send Events Operation
    User->>TinybirdBlock: Configure Send Events operation
    User->>TinybirdBlock: Provide datasource, data, token
    TinybirdBlock->>TinybirdBlock: Parse params & convert wait boolean
    TinybirdBlock->>ToolRegistry: Route to tinybird_events tool
    ToolRegistry->>EventsTool: Execute with params
    EventsTool->>EventsTool: Build URL with query params
    EventsTool->>EventsTool: Apply gzip compression (if enabled)
    EventsTool->>TinybirdAPI: POST /v0/events
    TinybirdAPI-->>EventsTool: Response with successful_rows, quarantined_rows
    EventsTool->>EventsTool: Transform response
    EventsTool-->>User: Return output

    Note over User,TinybirdAPI: Query Operation
    User->>TinybirdBlock: Configure Query operation
    User->>TinybirdBlock: Provide SQL query, token
    TinybirdBlock->>TinybirdBlock: Parse params
    TinybirdBlock->>ToolRegistry: Route to tinybird_query tool
    ToolRegistry->>QueryTool: Execute with params
    QueryTool->>QueryTool: Build form-encoded body
    QueryTool->>TinybirdAPI: POST /v0/sql
    TinybirdAPI-->>QueryTool: Response (JSON/CSV/TSV)
    QueryTool->>QueryTool: Detect format via content-type
    QueryTool->>QueryTool: Parse JSON or return raw text
    QueryTool-->>User: Return data, rows, statistics
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.

4 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@lakeesiv
Copy link
Author

@greptileai

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.

6 files reviewed, 6 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +104 to +115
output: {
data: data.data || [],
rows: data.rows || 0,
statistics: data.statistics
? {
elapsed: data.statistics.elapsed,
rows_read: data.statistics.rows_read,
bytes_read: data.statistics.bytes_read,
}
: undefined,
},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The JSON response handling assumes a specific structure (data.data, data.rows, data.statistics), but doesn't validate that these fields exist or have the expected types before accessing nested properties.

If Tinybird's API changes or returns a different structure, this could throw unexpected errors. Consider adding validation:

Suggested change
output: {
data: data.data || [],
rows: data.rows || 0,
statistics: data.statistics
? {
elapsed: data.statistics.elapsed,
rows_read: data.statistics.rows_read,
bytes_read: data.statistics.bytes_read,
}
: undefined,
},
}
return {
success: true,
output: {
data: Array.isArray(data.data) ? data.data : [],
rows: typeof data.rows === 'number' ? data.rows : 0,
statistics: data.statistics && typeof data.statistics === 'object'
? {
elapsed: data.statistics.elapsed ?? 0,
rows_read: data.statistics.rows_read ?? 0,
bytes_read: data.statistics.bytes_read ?? 0,
}
: undefined,
},
}
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/tools/tinybird/query.ts
Line: 104:115

Comment:
The JSON response handling assumes a specific structure (`data.data`, `data.rows`, `data.statistics`), but doesn't validate that these fields exist or have the expected types before accessing nested properties.

If Tinybird's API changes or returns a different structure, this could throw unexpected errors. Consider adding validation:

```suggestion
        return {
          success: true,
          output: {
            data: Array.isArray(data.data) ? data.data : [],
            rows: typeof data.rows === 'number' ? data.rows : 0,
            statistics: data.statistics && typeof data.statistics === 'object'
              ? {
                  elapsed: data.statistics.elapsed ?? 0,
                  rows_read: data.statistics.rows_read ?? 0,
                  bytes_read: data.statistics.bytes_read ?? 0,
                }
              : undefined,
          },
        }
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Author

Choose a reason for hiding this comment

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

If tinybirds api changes an error is better than whatever its suggested here

lakeesiv and others added 4 commits January 12, 2026 13:31
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@lakeesiv lakeesiv changed the base branch from main to staging January 12, 2026 22:59
const responseText = await response.text()
const contentType = response.headers.get('content-type') || ''

if (!response.ok) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

@lakeesiv one thing: if there is an error, it won't go into the transformResponse codepath and will go through the consolidated error service in the tools/ directory, I believe in executeTool, so we don't necessarily need error handling here and can solely rely on the error handling there. if tinybird throws a unqiue error type that is not already handled in the error extractor, then we can add the pattern there to make sure it actually extracts the error message. this goes for the events as well. besides that, LGTM

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.

4 participants