:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(warehouse_sources): support Factorial API version 2026-07-01 (#80082)
Tom Owers111b600a7288
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.mdindex 37abe3f6cab3..ddac8c1c4b84 100644--- a/.agents/skills/warehouse-source-new-version/SKILL.md+++ b/.agents/skills/warehouse-source-new-version/SKILL.md@@ -76,6 +76,7 @@ Add it when any of these hold:## Common pitfalls- Vendor version labels are opaque: `"2026-02-25.clover"`, `"v21.0"`, `"2022-06-28"`. Copy them exactly; never normalize, sort, or parse.+- A change the vendor calls "breaking" (e.g. resource ids migrating int→string) still needs no per-version branch when the source only passes the affected values through opaquely — a primary key whose _column name_ is stable (type auto-inferred), cursors forwarded verbatim. The version still has to exist (the gate passed on a real divergence), but branch the request path only where the change hits a surface you hardcode: column hints, a parsed cursor, a typed primary key.- A version bump often changes **webhook payloads** too — if the source is a `WebhookSource`, check whether webhook-created clients (created at source-setup time, not sync time) also need the version and whether existing webhook subscriptions must be updated.- Credential-validation paths (`validate_credentials`, permission probes) run at creation time with no row pin; they may use the default/legacy version. Changing them is optional per version bump — verify the vendor accepts the validation calls under the new version before switching them.- A passing credential probe is not evidence sync works — the probe hits one endpoint, `get_rows` hits the rest; when they diverge per version, the probe passes while every table 404s.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.md b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.mdindex 119630cde35b..68d976455c66 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/api_inventory.md@@ -7,11 +7,15 @@ Source-local notes for the Factorial (HRIS) connector. See the official referenc- **Host:** single global host `https://api.factorialhr.com` (no per-account subdomains).- **Version:** dated path segment → base `https://api.factorialhr.com/api/<version>`. Supported labels- `2025-04-01` and `2026-04-01` (default); the source's resolved pin is threaded into the base URL in- `factorial.py`. Resources occasionally move between groups across versions, but the resource paths and- the `{"meta": ..., "data": [...]}` envelope our reads use are identical across both supported labels- (`2026-04-01` only adds/removes response fields, which the auto-inferred schema absorbs). The id→string- identifier migration lands in the later `2026-07-01` version, so ids stay integers on both.+ `2025-04-01`, `2026-04-01`, and `2026-07-01` (default); the source's resolved pin is threaded into the+ base URL in `factorial.py`. Resources occasionally move between groups across versions, but the resource+ paths and the `{"meta": ..., "data": [...]}` envelope our reads use are identical across all three labels+ (newer versions only add/remove response fields, which the auto-inferred schema absorbs).+- **Identifier serialization:** `2026-07-01` ("Bessel") serializes every resource id as an opaque string+ instead of an integer (ids outgrew the safe 64-bit range) — in request params, responses, and webhooks.+ Our reads tolerate this without a version branch: the primary key stays the `id` column (type-agnostic,+ auto-inferred) and pagination forwards the opaque `meta.end_cursor`, never a raw record id. Pins on+ `2025-04-01` / `2026-04-01` keep integer ids.- **Auth:** `x-api-key: <key>` header (API key). OAuth2 is also supported by Factorial but not implementedhere — API key auth is fully supported for company/internal integrations and grants total account access.- **Resource path shape:** `/resources/<group>/<resource>` (e.g. `/resources/employees/employees`).diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/factorial.py b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/factorial.pyindex 7cd5e50fcd7a..adb7ee99d66f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/factorial.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/factorial.py@@ -18,9 +18,14 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.factorial.# path segment. Each label is a stable release; newer versions add or drop response fields (which the# auto-inferred schema turns into columns) but keep the `/resources/<group>/<resource>` paths and the# `{"meta": ..., "data": [...]}` envelope our reads depend on. Ordered oldest → newest.+#+# `2026-07-01` serializes every resource id as an opaque string instead of an integer (ids outgrew the+# safe 64-bit range). Our reads tolerate that: the primary key stays the `id` column (type-agnostic,+# auto-inferred) and pagination already forwards the opaque `meta.end_cursor`, never the raw record id.FACTORIAL_HOST = "https://api.factorialhr.com"API_VERSION_2025_04_01 = "2025-04-01"API_VERSION_2026_04_01 = "2026-04-01"+API_VERSION_2026_07_01 = "2026-07-01"def base_url(api_version: str) -> str:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/source.pyindex 9c93f343744f..969f93c93953 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/source.py@@ -20,6 +20,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.typfrom products.warehouse_sources.backend.temporal.data_imports.sources.factorial.factorial import (API_VERSION_2025_04_01,API_VERSION_2026_04_01,+ API_VERSION_2026_07_01,FactorialResumeConfig,factorial_source,validate_credentials as validate_factorial_credentials,@@ -38,8 +39,8 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.registerclass FactorialSource(ResumableSource[FactorialSourceConfig, FactorialResumeConfig]):lists_tables_without_credentials = True # static endpoint catalog — safe for public docs- supported_versions = (API_VERSION_2025_04_01, API_VERSION_2026_04_01)- default_version = API_VERSION_2026_04_01+ supported_versions = (API_VERSION_2025_04_01, API_VERSION_2026_04_01, API_VERSION_2026_07_01)+ default_version = API_VERSION_2026_07_01api_docs_url = "https://apidoc.factorialhr.com/docs/api-versioning"@propertydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.py b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.pyindex 0ab00f60cd96..3197d3e824b0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial.py@@ -11,6 +11,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resfrom products.warehouse_sources.backend.temporal.data_imports.sources.factorial.factorial import (API_VERSION_2025_04_01,API_VERSION_2026_04_01,+ API_VERSION_2026_07_01,PAGE_SIZE,FactorialCursorPaginator,FactorialResumeConfig,@@ -244,7 +245,7 @@ class TestFactorialSourceResumeBehavior:assert sent_params[0].get("after_id") == "MTY="manager.load_state.assert_called_once()- @pytest.mark.parametrize("api_version", [API_VERSION_2025_04_01, API_VERSION_2026_04_01])+ @pytest.mark.parametrize("api_version", [API_VERSION_2025_04_01, API_VERSION_2026_04_01, API_VERSION_2026_07_01])def test_requests_go_to_the_pinned_version_path(self, api_version: str) -> None:# A pinned source must fetch under its own version segment — never a hardcoded default.manager = MagicMock(spec=ResumableSourceManager)@@ -304,7 +305,7 @@ class TestValidateCredentials:else:assert error is not None- @pytest.mark.parametrize("api_version", [API_VERSION_2025_04_01, API_VERSION_2026_04_01])+ @pytest.mark.parametrize("api_version", [API_VERSION_2025_04_01, API_VERSION_2026_04_01, API_VERSION_2026_07_01])def test_probes_employees_endpoint_under_requested_version(self, api_version: str) -> None:with patch(_SESSION_FACTORY) as MockSession:mock_session = MockSession.return_valuediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial_source.pyindex ae2bb30d4ecb..4922719840f8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/factorial/tests/test_factorial_source.py@@ -130,7 +130,7 @@ class TestFactorialSource:assert is_valid is expected_validassert error_message == expected_message# No row pin at creation time, so the probe runs under the default (newest) version.- mock_validate.assert_called_once_with("test-key", "2026-04-01")+ mock_validate.assert_called_once_with("test-key", "2026-07-01")def test_get_resumable_source_manager_bound_to_resume_config(self) -> None:manager = self.source.get_resumable_source_manager(_make_inputs())@@ -141,9 +141,10 @@ class TestFactorialSource:("pin", "resolved"),[# None pin resolves to the default (the newest supported version) — new sources land here.- (None, "2026-04-01"),+ (None, "2026-07-01"),("2025-04-01", "2025-04-01"),("2026-04-01", "2026-04-01"),+ ("2026-07-01", "2026-07-01"),],)@mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.factorial.source.factorial_source")