PostHog / PostHog/posthog

Pipedrive warehouse sync crashes for field schema tables when generated subfields have null ids

Open
#67,150 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 Description

Pipedrive Data Warehouse sync can fail for the field-schema tables:

  • deal_fields
  • organization_fields
  • person_fields

In PostHog Cloud, the affected schema remains in Running with Rows synced = 0, and the job logs repeatedly show:

unsupported operand type(s) for //: 'NoneType' and 'int'

This appears to be caused by Pipedrive v1 field metadata returning generated subfield rows with id = null. These are normal Pipedrive metadata rows for complex/system fields, not malformed CRM records.

Examples of null-ID rows observed from Pipedrive v1 field endpoints:

  • deal_fields: currency, weighted_value_currency, mrr_currency, arr_currency, acv_currency
  • organization_fields: address_lat, address_long, address_subpremise, address_street_number, address_route
  • person_fields: postal_address_lat, postal_address_long, postal_address_subpremise, postal_address_street_number, postal_address_route

Pipedrive v2 represents these as nested subfields under parent fields and identifies them with string field_code values rather than standalone numeric IDs.

How to reproduce

  1. Configure a Pipedrive warehouse source where /api/v1/dealFields, /api/v1/personFields, or /api/v1/organizationFields returns generated subfield rows with id: null.
  2. Enable/sync deal_fields, organization_fields, and/or person_fields.
  3. The sync uses the default primary key id for these schemas.
  4. If the id column is inferred as numeric but contains nulls, numerical partitioning reaches:
partition = row[key] // partition_size

and crashes when row[key] is None.

Additional context

The current Pipedrive source config uses v1 endpoints for the affected schemas and defaults primary_key to id:

The source response then passes that primary key into the pipeline:

The partition helper can then choose numerical partitioning and crash on a nullable key:

Potential fixes:

  1. Best connector fix: move Pipedrive field-schema syncs to v2 field endpoints and key by field_code, using parent field_code + subfield field_code for nested subfields.
  2. Minimal connector fix: keep v1 endpoints but use key as the primary key for *_fields schemas instead of nullable id.
  3. Generic pipeline safety fix: do not choose numerical partitioning when the selected partition key contains nulls; fall back to md5 or skip partitioning.

Debug info

  • PostHog Cloud, Debug information: available privately if needed.
  • Source type: Pipedrive
  • Affected schemas: deal_fields, organization_fields, person_fields
  • Cloud source/job URL: available privately if needed.

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 with products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/settings.py and pipedrive.py to trace the affected schemas and primary keys, then inspect products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/utils.py around numerical partitioning. Decide between a connector-specific key or a generic nullable-key fallback, and verify that field-schema syncs complete without crashing on null IDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
54/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.