Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: supabase/orb-sync-engine
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.11.13
Choose a base ref
...
head repository: supabase/orb-sync-engine
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.11.14
Choose a head ref
  • 1 commit
  • 6 files changed
  • 1 contributor

Commits on Jul 1, 2025

  1. fix: prevent synced invoices from getting updated by outdated webhooks (

    #68)
    
    This PR introduces a general safeguard for upserting - the `upsertManyWithTimestampProtection` function. This function uses a SQL statement with a `WHERE` clause that only updates records when the incoming `last_synced_at` timestamp is newer than the existing one. This prevents older webhook events from overwriting newer data, ensuring data consistency. This pattern can easily be applied to other entities by using the same function in their respective sync functions.
    
    It also:
    - Adds a new migration to add the last_synced_at column to all entities: `invoices`, `customers`, `subscriptions`, `credit_notes`, `plans`, and `billable_metrics`
    - Adds the `syncTimestamp` parameter to the `syncInvoices` method allows webhook handlers to pass the webhook's `created_at` timestamp, which is then used as the `last_synced_at` value for timestamp-based protection
    - Adds assertions and tests to cover this functionality, including a new test case where we check that an invoice is not updated with an out-of-date webhook.
    ignaciodob authored Jul 1, 2025
    Configuration menu
    Copy the full SHA
    479da75 View commit details
    Browse the repository at this point in the history
Loading