PostHog / PostHog/posthog

Stripe Discount warehouse sync fails with KeyError: 'created'

Open
#71,826 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
6h 51m
Merged PRs (30d)
232

Description

Bug

Stripe Discount schema sync fails with:

KeyError: 'created'

Why

Stripe Discount objects expose start / end, not created (Discount object).

Empty Discount syncs succeed (0 rows, webhook-only short-circuit). Once real customer.discount.* events arrive (e.g. coupon applied to a subscription), the webhook→warehouse path crashes looking up created.

Repro

  1. Connect Stripe with Discount schema enabled (sync_type: webhook)
  2. Apply a coupon to a customer/subscription so customer.discount.created fires
  3. Observe Discount sync fail with KeyError: 'created'

Expected

Discount rows land in stripe_discount using start (or coalesce created/start) as the timestamp field.

Impact

  • Source shows Failed; Discount table never created
  • Under webhook mode, stripe_subscription.discounts is only ["di_…"] IDs with no join target
  • Other Stripe schemas continue syncing normally

Suggested fix

In the Stripe Discount webhook ingest path, do not assume obj['created'] — use start for Discount objects.

Context

  • Cloud project, Stripe API version pinned to 2024-09-30.acacia
  • Also reported via PostHog agent-feedback channel

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the Stripe Discount webhook ingest path and search for the lookup of obj['created']; inspect how customer.discount.* events are transformed for warehouse sync. Reproduce with a real Discount event, then verify that a stripe_discount row is created using the Discount timestamp and that other Stripe schemas continue syncing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, data-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.