Pipedrive warehouse sync crashes for field schema tables when generated subfields have null ids
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_fieldsorganization_fieldsperson_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_currencyorganization_fields:address_lat,address_long,address_subpremise,address_street_number,address_routeperson_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
- Configure a Pipedrive warehouse source where
/api/v1/dealFields,/api/v1/personFields, or/api/v1/organizationFieldsreturns generated subfield rows withid: null. - Enable/sync
deal_fields,organization_fields, and/orperson_fields. - The sync uses the default primary key
idfor these schemas. - If the
idcolumn 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:
- https://github.com/PostHog/posthog/blob/master/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/settings.py#L13
- https://github.com/PostHog/posthog/blob/master/products/warehouse_sources/backend/temporal/data_imports/sources/pipedrive/settings.py#L31-L39
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:
- Best connector fix: move Pipedrive field-schema syncs to v2 field endpoints and key by
field_code, usingparent field_code + subfield field_codefor nested subfields. - Minimal connector fix: keep v1 endpoints but use
keyas the primary key for*_fieldsschemas instead of nullableid. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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