Skip to content

feat(triggers): add Linear v2 triggers with automatic webhook registration#3991

Merged
waleedlatif1 merged 5 commits intostagingfrom
waleedlatif1/add-linear-trigger
Apr 6, 2026
Merged

feat(triggers): add Linear v2 triggers with automatic webhook registration#3991
waleedlatif1 merged 5 commits intostagingfrom
waleedlatif1/add-linear-trigger

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add 15 v2 Linear triggers with automatic webhook creation/deletion via Linear GraphQL API
  • V2 triggers use API key auth to register webhooks automatically — no manual URL copy/paste
  • Add createSubscription/deleteSubscription to Linear provider handler
  • V1 triggers fully preserved and backwards compatible (hideFromToolbar + separate registry entries)
  • LinearV2Block replaces LinearBlock in toolbar while existing v1 workflows continue working

Type of Change

  • New feature

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)

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 6, 2026

PR Summary

Medium Risk
Adds automatic Linear webhook create/delete via the Linear GraphQL API and new v2 trigger IDs, which changes how subscriptions are managed and introduces reliance on external API/key configuration.

Overview
Introduces a new Linear v2 trigger set that uses an API key to automatically create/delete Linear webhooks, eliminating manual webhook URL/secret setup.

Adds LinearV2Block (toolbar-visible) while renaming/hiding the existing LinearBlock as Legacy to keep existing workflows working, and registers the new linear_v2 block and 15 _v2 triggers in the block/trigger registries.

Extends the Linear webhook provider with matchEvent filtering for non-“all events” triggers and createSubscription/deleteSubscription logic that calls Linear’s GraphQL API, persists externalId + generated webhookSecret, and maps trigger IDs to Linear resourceTypes via a new LINEAR_RESOURCE_TYPE_MAP plus shared v2 sub-block builder/instructions.

Reviewed by Cursor Bugbot for commit f6ea743. Configure here.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 6, 2026 8:35pm

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 6, 2026

Greptile Summary

This PR adds 15 Linear v2 triggers with automatic webhook lifecycle management — users provide an API key and Sim registers/deregisters webhooks in Linear automatically via the GraphQL API, replacing the manual copy-paste flow of the v1 triggers.

  • linearHandler.createSubscription: POSTs a WebhookCreate GraphQL mutation using the user's API key, scopes resource types per LINEAR_RESOURCE_TYPE_MAP, generates a fresh HMAC secret via generateId(), and stores externalId + webhookSecret in providerConfig
  • linearHandler.deleteSubscription: Calls WebhookDelete on teardown; failures are non-fatal (warn + return), so trigger deletion is never blocked by transient errors
  • buildLinearV2SubBlocks: Shared factory that builds apiKey, teamId, triggerSave, and triggerInstructions sub-blocks, all gated by a selectedTriggerId condition; only linearIssueCreatedV2Trigger includes the dropdown (includeDropdown: true)
  • LinearV2Block: Spreads all 15 v2 triggers' sub-blocks into one unified block using the shared dropdown to control visibility via conditions — a clean extension of the existing v1 pattern
  • Backwards compatibility: All v1 Linear triggers are preserved with hideFromToolbar: true on LinearBlock; existing workflows continue to work
  • Event matching: isLinearEventMatch strips the _v2 suffix before lookup so both v1 and v2 triggers share the same action/type map, and _webhook_v2 correctly bypasses action filtering to pass all events through

Confidence Score: 5/5

Safe to merge — all remaining findings are P2 style/observability suggestions; no correctness, security, or data-integrity issues found

The HTTP-status-check concern from a prior review was already resolved. Core logic (webhook registration, HMAC verification, event routing, delete cleanup, backwards compatibility) is correct and well-guarded. All project rules are followed: user-only visibility for the API key, generateId() for the webhook secret, createLogger for all logging, absolute imports, and no console.log.

No files require special attention. apps/sim/lib/webhooks/providers/linear.ts is the most critical file (external API calls + secret handling) and is correctly implemented.

Important Files Changed

Filename Overview
apps/sim/lib/webhooks/providers/linear.ts Adds createSubscription/deleteSubscription with HTTP status checks, HMAC-SHA256 verification, and graceful non-fatal delete handling
apps/sim/triggers/linear/utils.ts Adds LINEAR_RESOURCE_TYPE_MAP, linearV2TriggerOptions, buildLinearV2SubBlocks factory, isLinearEventMatch (shared v1/v2), and rich output-schema builders for all 15 trigger types
apps/sim/blocks/blocks/linear.ts Adds LinearV2Block spreading all v2 trigger subBlocks with shared-dropdown condition pattern; LinearBlock marked hideFromToolbar: true for backwards compat
apps/sim/triggers/registry.ts Registers 15 new v2 Linear triggers alongside all existing v1 entries
apps/sim/triggers/linear/index.ts Re-exports all v1 and v2 Linear triggers cleanly
apps/sim/triggers/linear/webhook_v2.ts Defines the all-events general webhook v2 trigger using the shared factory
apps/sim/triggers/linear/issue_created_v2.ts Primary v2 trigger (includeDropdown: true) that anchors the shared trigger-type dropdown for the LinearV2Block

Sequence Diagram

sequenceDiagram
    participant User
    participant LinearV2Block
    participant Sim
    participant LinearAPI

    User->>LinearV2Block: Enter API Key + optional Team ID,<br/>select trigger type via dropdown
    User->>LinearV2Block: Click Save Configuration
    LinearV2Block->>Sim: createSubscription()
    Note over Sim: Look up resourceTypes via LINEAR_RESOURCE_TYPE_MAP<br/>Generate webhookSecret = generateId()
    Sim->>LinearAPI: POST /graphql — WebhookCreate mutation<br/>(url, resourceTypes, secret, teamId | allPublicTeams)
    LinearAPI-->>Sim: { success: true, webhook: { id } }
    Note over Sim: Store externalId + webhookSecret in providerConfig

    Note over LinearAPI,Sim: Later: Linear fires an event

    LinearAPI->>Sim: POST /api/webhooks/trigger/{path}<br/>Linear-Signature: hmac-sha256 header
    Note over Sim: verifyAuth — HMAC-SHA256(webhookSecret, rawBody)
    Note over Sim: matchEvent — isLinearEventMatch(triggerId, type, action)<br/>strips _v2 suffix; _webhook_v2 always passes
    alt type + action matches triggerId
        Sim-->>LinearAPI: 200 OK — workflow executes
    else No match
        Note over Sim: Skip — log mismatch, no workflow run
    end

    Note over User,Sim: On trigger delete
    User->>LinearV2Block: Remove trigger
    LinearV2Block->>Sim: deleteSubscription()
    Sim->>LinearAPI: POST /graphql — WebhookDelete(id: externalId)
    LinearAPI-->>Sim: { success: true }
    Note over Sim: Non-fatal — warn + return on any error
Loading

Reviews (4): Last reviewed commit: "fix build" | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

Both issues addressed in fd7c856:

  1. response.ok checks — added before response.json() in both createSubscription (throws clear HTTP status error) and deleteSubscription (logs warning + returns early).

  2. as any → as unknown as Record<string, TriggerOutput> — replaced all 7 casts. The underlying issue is that TriggerOutput's index signature conflicts with nested objects that have a description property (it matches both the index sig's string | undefined and a TriggerOutput child). Direct cast to Record<string, TriggerOutput> fails, so as unknown as is the correct explicit assertion here.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit fd7c856. Configure here.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f6ea743. Configure here.

@waleedlatif1 waleedlatif1 merged commit 5ea63f1 into staging Apr 6, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/add-linear-trigger branch April 6, 2026 20:50
emir-karabeg pushed a commit that referenced this pull request Apr 7, 2026
…ation (#3991)

* feat(triggers): add Linear v2 triggers with automatic webhook registration

* fix(triggers): preserve specific Linear API error messages in catch block

* fix(triggers): check response.ok before JSON parsing, replace as any with as unknown

* fix linear subscription params

* fix build

---------

Co-authored-by: Vikhyath Mondreti <vikhyath@simstudio.ai>
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