Skip to content

: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.

feat(warehouse_sources): support inFlow Inventory API version 2026-07-10 (#80084)

Tom Owers290255cf15af
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/inflowinventory.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/inflowinventory.py
index 1eb5ec68a9a5..ef7d1cb96c0c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/inflowinventory.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/inflowinventory.py
@@ -19,8 +19,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.inflowinve
)
INFLOWINVENTORY_BASE_URL = "https://cloudapi.inflowinventory.com"
-# inFlow requires a date-based API version header on every request; pin a recent documented version.
-INFLOWINVENTORY_API_VERSION = "2023-04-01"
+# inFlow requires a date-based API version on every request, sent in the Accept header. The resolved
+# source pin selects which of these labels is sent, so previously-created sources keep their behaviour.
+INFLOWINVENTORY_API_VERSION_2023_04_01 = "2023-04-01"
+INFLOWINVENTORY_API_VERSION_2026_07_10 = "2026-07-10"
# The list endpoints accept up to 100 records per page; the largest page minimises round trips.
PAGE_SIZE = 100
# inFlow company IDs are GUIDs. Restrict to host/path-safe characters so the credential stays
@@ -40,22 +42,22 @@ def base_url(company_id: str) -> str:
return f"{INFLOWINVENTORY_BASE_URL}/{company_id}"
-def _version_headers() -> dict[str, str]:
+def _version_headers(api_version: str) -> dict[str, str]:
# Auth (Bearer) is supplied via the framework auth config so its value is redacted from logs and
# raised error messages; only the non-secret version/accept header is set here.
- return {"Accept": f"application/json;version={INFLOWINVENTORY_API_VERSION}"}
+ return {"Accept": f"application/json;version={api_version}"}
-def _headers(api_key: str) -> dict[str, str]:
- return {"Authorization": f"Bearer {api_key}", **_version_headers()}
+def _headers(api_key: str, api_version: str) -> dict[str, str]:
+ return {"Authorization": f"Bearer {api_key}", **_version_headers(api_version)}
-def _make_session(api_key: str) -> requests.Session:
+def _make_session(api_key: str, api_version: str) -> requests.Session:
# Redirects are pinned off so the Bearer key can't be replayed to a cross-host redirect target
# (SSRF / credential-exfiltration defense). urllib3 retries are disabled — the credential probe
# is a single request that must not silently retry a transient failure.
return make_tracked_session(
- headers=_headers(api_key), redact_values=(api_key,), allow_redirects=False, retry=Retry(total=0)
+ headers=_headers(api_key, api_version), redact_values=(api_key,), allow_redirects=False, retry=Retry(total=0)
)
@@ -121,6 +123,7 @@ def inflowinventory_source(
team_id: int,
job_id: str,
resumable_source_manager: ResumableSourceManager[InflowInventoryResumeConfig],
+ api_version: str,
db_incremental_field_last_value: Optional[Any] = None,
) -> SourceResponse:
config = INFLOWINVENTORY_ENDPOINTS[endpoint]
@@ -128,7 +131,7 @@ def inflowinventory_source(
rest_config: RESTAPIConfig = {
"client": {
"base_url": base_url(company_id),
- "headers": _version_headers(),
+ "headers": _version_headers(api_version),
"auth": {"type": "bearer", "token": api_key},
"paginator": InflowInventoryPaginator(id_field=config.id_field, page_size=PAGE_SIZE),
# Pin every request (including resume URLs) to the base_url host and reject any redirect
@@ -183,7 +186,7 @@ def inflowinventory_source(
)
-def check_access(api_key: str, company_id: str, path: str = "products") -> tuple[int, Optional[str]]:
+def check_access(api_key: str, company_id: str, api_version: str, path: str = "products") -> tuple[int, Optional[str]]:
"""Probe a single endpoint to validate the credentials.
Returns ``(status, message)``: ``200`` reachable, ``401``/``403`` auth failure, ``0`` for a
@@ -192,7 +195,7 @@ def check_access(api_key: str, company_id: str, path: str = "products") -> tuple
if not COMPANY_ID_REGEX.match(company_id):
return 400, "The inFlow Inventory company ID contains unsupported characters"
- session = _make_session(api_key)
+ session = _make_session(api_key, api_version)
try:
response = session.get(f"{base_url(company_id)}/{path}", params={"count": 1}, timeout=15)
except Exception as e:
@@ -207,8 +210,8 @@ def check_access(api_key: str, company_id: str, path: str = "products") -> tuple
return 200, None
-def validate_credentials(api_key: str, company_id: str) -> tuple[bool, str | None]:
- status, message = check_access(api_key, company_id)
+def validate_credentials(api_key: str, company_id: str, api_version: str) -> tuple[bool, str | None]:
+ status, message = check_access(api_key, company_id, api_version)
if status == 200:
return True, None
if status in (401, 403):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/source.py
index a893b8ddebf3..00ca39793c00 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/source.py
@@ -21,6 +21,8 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_
InflowinventorySourceConfig,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.inflowinventory.inflowinventory import (
+ INFLOWINVENTORY_API_VERSION_2023_04_01,
+ INFLOWINVENTORY_API_VERSION_2026_07_10,
InflowInventoryResumeConfig,
inflowinventory_source,
validate_credentials,
@@ -34,8 +36,10 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
class InflowinventorySource(ResumableSource[InflowinventorySourceConfig, InflowInventoryResumeConfig]):
- supported_versions = ("2023-04-01",)
- default_version = "2023-04-01"
+ # Oldest → newest. inFlow's version is a request input (the Accept header), so each pin keeps
+ # sending its own label; new sources default to the current stable version.
+ supported_versions = (INFLOWINVENTORY_API_VERSION_2023_04_01, INFLOWINVENTORY_API_VERSION_2026_07_10)
+ default_version = INFLOWINVENTORY_API_VERSION_2026_07_10
api_docs_url = "https://cloudapi.inflowinventory.com/docs"
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
@@ -134,7 +138,7 @@ Find your company ID and create an API key on the **Integrations** page in [inFl
api_version: str | None = None,
) -> tuple[bool, str | None]:
# The API key is account-wide, so a single probe validates access to every schema.
- return validate_credentials(config.api_key, config.company_id)
+ return validate_credentials(config.api_key, config.company_id, self.resolve_api_version(api_version))
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[InflowInventoryResumeConfig]:
return ResumableSourceManager[InflowInventoryResumeConfig](inputs, InflowInventoryResumeConfig)
@@ -155,4 +159,5 @@ Find your company ID and create an API key on the **Integrations** page in [inFl
team_id=inputs.team_id,
job_id=inputs.job_id,
resumable_source_manager=resumable_source_manager,
+ api_version=self.resolve_api_version(inputs.api_version),
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory.py
index d343e7f5af1c..f6949d97bef0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory.py
@@ -11,7 +11,8 @@ from requests import Response
from products.warehouse_sources.backend.temporal.data_imports.sources.inflowinventory import inflowinventory
from products.warehouse_sources.backend.temporal.data_imports.sources.inflowinventory.inflowinventory import (
- INFLOWINVENTORY_API_VERSION,
+ INFLOWINVENTORY_API_VERSION_2023_04_01,
+ INFLOWINVENTORY_API_VERSION_2026_07_10,
PAGE_SIZE,
InflowInventoryResumeConfig,
check_access,
@@ -73,7 +74,7 @@ def _rows(source_response: Any) -> list[dict[str, Any]]:
return [row for page in source_response.items() for row in page]
-def _source(endpoint: str, manager: MagicMock) -> Any:
+def _source(endpoint: str, manager: MagicMock, api_version: str = INFLOWINVENTORY_API_VERSION_2026_07_10) -> Any:
return inflowinventory_source(
api_key="inflow-key",
company_id="co-123",
@@ -81,6 +82,7 @@ def _source(endpoint: str, manager: MagicMock) -> Any:
team_id=1,
job_id="j",
resumable_source_manager=manager,
+ api_version=api_version,
)
@@ -182,13 +184,21 @@ class TestPagination:
_rows(_source("sales_orders", _make_manager()))
assert snapshots[0]["url"] == "https://cloudapi.inflowinventory.com/co-123/sales-orders"
+ @parameterized.expand(
+ [
+ ("legacy", INFLOWINVENTORY_API_VERSION_2023_04_01),
+ ("current", INFLOWINVENTORY_API_VERSION_2026_07_10),
+ ]
+ )
@mock.patch(CLIENT_SESSION_PATCH)
- def test_version_header_is_set_on_session(self, MockSession: MagicMock) -> None:
+ def test_resolved_version_reaches_session_header(
+ self, _name: str, api_version: str, MockSession: MagicMock
+ ) -> None:
session = MockSession.return_value
_wire(session, [_json_response([])])
- _rows(_source("products", _make_manager()))
- assert session.headers.get("Accept") == f"application/json;version={INFLOWINVENTORY_API_VERSION}"
+ _rows(_source("products", _make_manager(), api_version=api_version))
+ assert session.headers.get("Accept") == f"application/json;version={api_version}"
@parameterized.expand([("rate_limited", 429), ("server_error", 500), ("bad_gateway", 503)])
@mock.patch("time.sleep")
@@ -260,19 +270,41 @@ class TestCheckAccess:
response.status_code = status
response.ok = ok
mock_make_session.return_value = self._build_session(response)
- assert check_access("inflow-key", "co-123") == (expected_status, expected_message)
+ assert check_access("inflow-key", "co-123", INFLOWINVENTORY_API_VERSION_2026_07_10) == (
+ expected_status,
+ expected_message,
+ )
+
+ @parameterized.expand(
+ [
+ ("legacy", INFLOWINVENTORY_API_VERSION_2023_04_01),
+ ("current", INFLOWINVENTORY_API_VERSION_2026_07_10),
+ ]
+ )
+ @mock.patch.object(inflowinventory, "make_tracked_session")
+ def test_probe_session_carries_resolved_version(
+ self, _name: str, api_version: str, mock_make_session: MagicMock
+ ) -> None:
+ response = MagicMock()
+ response.status_code = 200
+ response.ok = True
+ mock_make_session.return_value = self._build_session(response)
+
+ check_access("inflow-key", "co-123", api_version)
+ headers = mock_make_session.call_args.kwargs["headers"]
+ assert headers["Accept"] == f"application/json;version={api_version}"
def test_malformed_company_id_short_circuits(self, monkeypatch: Any) -> None:
# A bad company ID never reaches the network — no session is created.
session = self._patch_session(monkeypatch, MagicMock())
- status, message = check_access("inflow-key", "bad id/../evil")
+ status, message = check_access("inflow-key", "bad id/../evil", INFLOWINVENTORY_API_VERSION_2026_07_10)
assert status == 400
assert message is not None
session.get.assert_not_called()
def test_connection_error_maps_to_zero(self, monkeypatch: Any) -> None:
self._patch_session(monkeypatch, requests.ConnectionError("boom"))
- status, message = check_access("inflow-key", "co-123")
+ status, message = check_access("inflow-key", "co-123", INFLOWINVENTORY_API_VERSION_2026_07_10)
assert status == 0
assert message is not None and "boom" in message
@@ -297,7 +329,10 @@ class TestCheckAccess:
response.status_code = status
response.ok = status < 400
mock_make_session.return_value = self._build_session(response)
- assert validate_credentials("inflow-key", "co-123") == (expected_valid, expected_message)
+ assert validate_credentials("inflow-key", "co-123", INFLOWINVENTORY_API_VERSION_2026_07_10) == (
+ expected_valid,
+ expected_message,
+ )
class TestInflowInventorySourceResponse:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory_source.py
index 3cf45bcf6572..f1b9b4f59272 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/inflowinventory/tests/test_inflowinventory_source.py
@@ -144,17 +144,49 @@ class TestInflowinventorySource:
assert is_valid is expected_valid
assert returned == expected_message
+ @parameterized.expand(
+ [
+ ("pinned_legacy", "2023-04-01", "2023-04-01"),
+ ("unpinned_resolves_to_default", None, "2026-07-10"),
+ ]
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.inflowinventory.source.validate_credentials"
+ )
+ def test_validate_credentials_probes_under_resolved_version(
+ self, _name: str, pinned: str | None, expected_version: str, mock_validate: mock.MagicMock
+ ) -> None:
+ mock_validate.return_value = (True, None)
+ self.source.validate_credentials(self.config, self.team_id, api_version=pinned)
+ assert mock_validate.call_args.args == ("inflow-key", "co-123", expected_version)
+
def test_get_resumable_source_manager_binds_resume_config(self) -> None:
manager = self.source.get_resumable_source_manager(mock.MagicMock())
assert isinstance(manager, ResumableSourceManager)
assert manager._data_class is InflowInventoryResumeConfig
+ def test_version_declaration(self) -> None:
+ # New sources default to the current stable version; the legacy pin stays supported so
+ # existing sources keep syncing under their own version.
+ assert self.source.default_version == "2026-07-10"
+ assert set(self.source.supported_versions) == {"2023-04-01", "2026-07-10"}
+
+ @parameterized.expand(
+ [
+ ("pinned_legacy", "2023-04-01", "2023-04-01"),
+ ("pinned_current", "2026-07-10", "2026-07-10"),
+ ("unpinned_resolves_to_default", None, "2026-07-10"),
+ ]
+ )
@mock.patch(
"products.warehouse_sources.backend.temporal.data_imports.sources.inflowinventory.source.inflowinventory_source"
)
- def test_source_for_pipeline_plumbs_arguments(self, mock_source: mock.MagicMock) -> None:
+ def test_source_for_pipeline_plumbs_arguments(
+ self, _name: str, pinned: str | None, expected_version: str, mock_source: mock.MagicMock
+ ) -> None:
inputs = mock.MagicMock()
inputs.schema_name = "products"
+ inputs.api_version = pinned
manager = mock.MagicMock()
self.source.source_for_pipeline(self.config, manager, inputs)
@@ -165,6 +197,7 @@ class TestInflowinventorySource:
assert kwargs["company_id"] == "co-123"
assert kwargs["endpoint"] == "products"
assert kwargs["resumable_source_manager"] is manager
+ assert kwargs["api_version"] == expected_version
def test_source_for_pipeline_rejects_unknown_schema(self) -> None:
inputs = mock.MagicMock()