Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • add grain key to idempotency service to avoid duplicate events

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 Jan 7, 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 7, 2026 7:52pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 7, 2026

Greptile Summary

Added extractGrainIdentifier function to extract unique identifiers from Grain webhook payloads to prevent duplicate event processing.

  • Implemented identifier extraction using type:id pattern (e.g., "recording_added:uuid-123")
  • Follows established pattern from other providers (Linear, Jira)
  • Registered extractor in PROVIDER_EXTRACTORS registry
  • Integrates with existing idempotency service at apps/sim/lib/webhooks/provider-utils.ts:442

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The change follows an established pattern used by 8 other providers in the same file. The implementation correctly extracts unique identifiers from Grain webhook payloads (confirmed by examining apps/sim/triggers/grain/utils.ts:36-37). The function properly handles null cases and integrates seamlessly with the existing idempotency service.
  • No files require special attention

Important Files Changed

Filename Overview
apps/sim/lib/webhooks/provider-utils.ts Added Grain provider identifier extractor to prevent duplicate webhook events

Sequence Diagram

sequenceDiagram
    participant GW as Grain Webhook
    participant IS as IdempotencyService
    participant PU as provider-utils
    participant Cache as Redis/DB
    
    GW->>IS: Webhook Event {type, data: {id}}
    IS->>IS: createWebhookIdempotencyKey()
    IS->>PU: extractProviderIdentifierFromBody("grain", body)
    PU->>PU: extractGrainIdentifier(body)
    PU->>PU: Check body.type && body.data?.id
    PU-->>IS: Return "type:id" (e.g. "recording_added:uuid")
    IS->>IS: normalizeKey(provider, identifier)
    IS->>Cache: Check if key exists
    alt Key exists (duplicate)
        Cache-->>IS: Previous result
        IS-->>GW: Return cached result (skip processing)
    else Key doesn't exist (first time)
        Cache-->>IS: Not found
        IS->>Cache: Store key with in-progress status
        IS->>IS: Execute webhook operation
        IS->>Cache: Store completed result
        IS-->>GW: Return result
    end
Loading

@waleedlatif1 waleedlatif1 merged commit 142c9a0 into staging Jan 7, 2026
10 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/grain branch January 7, 2026 20:00
waleedlatif1 added a commit that referenced this pull request Jan 8, 2026
* fix(grain): add grain key to idempotency service

* fixed dropdown issue for grain, webhook registration
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