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(data-warehouse): add 7 missing Linear tables (#77270)

Tom Owersb0b79538fcd1
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md
index 68f86d2f326d..1b3d12bd0737 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md
@@ -335,18 +335,22 @@ campaign_stats_daily_demographics, ad_stats_daily_country, ad_stats_daily_demogr
- [ ] Organization-level tables — funding sources, billing centers, invoices, members (skipped: all
scoped to an organization ID this source does not collect).
-### Linear — needs confirmation
-
-Eight tables. Two small additions unblock the cycle-time use case.
-
-- [ ] `workflow_states` — issues carry a state ID with no way to resolve it to a name or type (backlog / started / completed). Highest value item.
-- [ ] `issue_history` — state transitions over time. Without it, cycle time, lead time, and time-in-state cannot be computed.
-- [ ] `project_milestones`, `initiatives`, `roadmaps`.
-- [ ] `attachments` — links out to PRs and tickets, which is how Linear connects to GitHub.
-- [ ] `issue_relations` — blocks / blocked-by / duplicates.
-- [ ] `project_updates`, `documents`.
-- [ ] `team_memberships`, `organization`.
-- [ ] Custom views, templates, reactions, triage responsibilities.
+### Linear — spec-verified
+
+Verified 2026-08-04 against the root `Query` type published by `@linear/sdk` 89.0.0 (npm), which is
+generated from Linear's live GraphQL schema.
+
+Have: issues, projects, teams, users, comments, labels, cycles, resources, workflow_states,
+project_milestones, initiatives, team_memberships, issue_relations, project_updates, documents.
+
+- [x] `workflow_states` — issues carry a state ID with no way to resolve it to a name or type (backlog / started / completed). Highest value item.
+- [ ] `issue_history` — state transitions over time. Without it, cycle time, lead time, and time-in-state cannot be computed. (skipped: no root `issueHistory` query — history is only reachable as `issue(id).history`, so it would need a per-issue fan-out)
+- [x] `project_milestones`, [x] `initiatives`, [ ] `roadmaps` (skipped: the schema marks `roadmaps` deprecated in favour of `initiatives`)
+- [x] `attachments` — links out to PRs and tickets, which is how Linear connects to GitHub. (already shipped as the `resources` table)
+- [x] `issue_relations` — blocks / blocked-by / duplicates.
+- [x] `project_updates`, [x] `documents`.
+- [x] `team_memberships`, [ ] `organization` (skipped: a singleton object, not a paginated connection)
+- [ ] Custom views, templates, reactions, triage responsibilities. (skipped: `templates` returns a plain list with no pagination, and there is no root `reactions` query; custom views and triage responsibilities are UI configuration rather than analyzable records)
## Tier 2
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/canonical_descriptions.py
index f13238a621e6..1509420df326 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/canonical_descriptions.py
@@ -132,4 +132,109 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
source="Information about the integration or service that created the attachment.",
),
},
+ "workflow_states": {
+ "description": "An issue workflow state (status) belonging to a team, such as Todo, In Progress, or Done.",
+ "docs_url": "https://developers.linear.app/docs/graphql/working-with-the-graphql-api",
+ "columns": _columns(
+ name="The state's name.",
+ type="Category of the state: triage, backlog, unstarted, started, completed, or canceled.",
+ color="The state's UI color, as a hex value.",
+ description="Description of the state.",
+ position="The state's position in the team's workflow.",
+ team="The team this workflow state belongs to.",
+ inheritedFrom="The workspace-level state this team state was inherited from, if any.",
+ ),
+ },
+ "project_milestones": {
+ "description": "A milestone marking a checkpoint within a project, grouping issues due by a target date.",
+ "docs_url": "https://developers.linear.app/docs/graphql/working-with-the-graphql-api",
+ "columns": _columns(
+ name="The milestone's name.",
+ description="Description of the milestone.",
+ status="Current status of the milestone (unstarted, next, overdue, or done).",
+ progress="Completion progress of the milestone, from 0 to 1.",
+ sortOrder="Position of the milestone within its project.",
+ targetDate="Date by which the milestone should be completed.",
+ project="The project the milestone belongs to.",
+ ),
+ },
+ "initiatives": {
+ "description": "A strategic goal that groups related projects together across the workspace.",
+ "docs_url": "https://developers.linear.app/docs/graphql/working-with-the-graphql-api",
+ "columns": _columns(
+ name="The initiative's name.",
+ description="Short summary of the initiative.",
+ content="The initiative's full description in markdown.",
+ slugId="URL-friendly identifier for the initiative.",
+ status="Current status of the initiative (Planned, Active, or Completed).",
+ health="Health reported in the initiative's latest update (onTrack, atRisk, or offTrack).",
+ priority="Priority of the initiative (0 = no priority, 1 = urgent, 2 = high, 3 = normal, 4 = low).",
+ sortOrder="Position of the initiative in the workspace list.",
+ targetDate="Date by which the initiative should be completed.",
+ targetDateResolution="Granularity of the target date (day, month, quarter, or year).",
+ startedAt="Time at which the initiative was moved into a started status.",
+ completedAt="Time at which the initiative was completed.",
+ healthUpdatedAt="Time at which the initiative's health was last updated.",
+ trashed="Whether the initiative has been moved to the trash.",
+ creator="The user who created the initiative.",
+ owner="The user who owns the initiative.",
+ parentInitiative="The parent initiative, if this initiative is nested.",
+ url="Link to the initiative in the Linear app.",
+ ),
+ },
+ "team_memberships": {
+ "description": "The membership of a user in a team, including whether they own it.",
+ "docs_url": "https://developers.linear.app/docs/graphql/working-with-the-graphql-api",
+ "columns": _columns(
+ owner="Whether the user is an owner of the team.",
+ sortOrder="Position of the team in the user's team list.",
+ team="The team the membership belongs to.",
+ user="The user who is a member of the team.",
+ ),
+ },
+ "issue_relations": {
+ "description": "A directed relationship between two issues, such as blocks, blocked by, related, or duplicate.",
+ "docs_url": "https://developers.linear.app/docs/graphql/working-with-the-graphql-api",
+ "columns": _columns(
+ type="The type of relation: blocks, duplicate, related, or similar.",
+ issue="The issue the relation starts from.",
+ relatedIssue="The issue on the other side of the relation.",
+ ),
+ },
+ "project_updates": {
+ "description": "A written status update posted on a project, recording its health at a point in time.",
+ "docs_url": "https://developers.linear.app/docs/graphql/working-with-the-graphql-api",
+ "columns": _columns(
+ body="The update's content in markdown.",
+ health="Health reported in the update (onTrack, atRisk, or offTrack).",
+ url="Link to the update in the Linear app.",
+ slugId="URL-friendly identifier for the update.",
+ commentCount="Number of comments left on the update.",
+ isStale="Whether the update is stale because a newer one has been posted.",
+ isDiffHidden="Whether the diff between this update and the previous one is hidden.",
+ diffMarkdown="Markdown diff between this update and the previous one.",
+ editedAt="Time at which the update was last edited.",
+ project="The project the update was posted on.",
+ user="The user who posted the update.",
+ ),
+ },
+ "documents": {
+ "description": "A document written in Linear, optionally attached to a project, initiative, or issue.",
+ "docs_url": "https://developers.linear.app/docs/graphql/working-with-the-graphql-api",
+ "columns": _columns(
+ title="The document's title.",
+ content="The document's content in markdown.",
+ icon="Icon shown for the document.",
+ color="The document's color, as a hex value.",
+ slugId="URL-friendly identifier for the document.",
+ url="Link to the document in the Linear app.",
+ trashed="Whether the document has been moved to the trash.",
+ hiddenAt="Time at which the document was hidden.",
+ creator="The user who created the document.",
+ updatedBy="The user who last updated the document.",
+ project="The project the document belongs to, if any.",
+ initiative="The initiative the document belongs to, if any.",
+ issue="The issue the document belongs to, if any.",
+ ),
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.py
index 352768781350..633be0d262d0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/linear.py
@@ -67,6 +67,12 @@ def _wait_strategy(retry_state: RetryCallState) -> float:
_FLOAT_FIELDS: dict[str, tuple[str, ...]] = {
"cycles": ("progress",),
"projects": ("progress",),
+ # `progress`, `sortOrder` and `position` are all GraphQL Floats that routinely hold whole
+ # values, so they hit the same int64-inference trap as `progress` above.
+ "workflow_states": ("position",),
+ "project_milestones": ("progress", "sortOrder"),
+ "initiatives": ("sortOrder",),
+ "team_memberships": ("sortOrder",),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/queries.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/queries.py
index efb7a0cf1c65..c67d06e592d2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/queries.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/queries.py
@@ -167,6 +167,162 @@ query PaginatedAttachments($pageSize: Int!, $cursor: String, $filter: Attachment
}
}"""
+WORKFLOW_STATES_QUERY = """
+query PaginatedWorkflowStates($pageSize: Int!, $cursor: String, $filter: WorkflowStateFilter) {
+ workflowStates(first: $pageSize, after: $cursor, orderBy: updatedAt, filter: $filter) {
+ nodes {
+ id
+ name
+ type
+ color
+ description
+ position
+ createdAt
+ updatedAt
+ archivedAt
+ team { id name key }
+ inheritedFrom { id name }
+ }
+ pageInfo { hasNextPage endCursor }
+ }
+}"""
+
+PROJECT_MILESTONES_QUERY = """
+query PaginatedProjectMilestones($pageSize: Int!, $cursor: String, $filter: ProjectMilestoneFilter) {
+ projectMilestones(first: $pageSize, after: $cursor, orderBy: updatedAt, filter: $filter) {
+ nodes {
+ id
+ name
+ description
+ status
+ progress
+ sortOrder
+ targetDate
+ createdAt
+ updatedAt
+ archivedAt
+ project { id name }
+ }
+ pageInfo { hasNextPage endCursor }
+ }
+}"""
+
+INITIATIVES_QUERY = """
+query PaginatedInitiatives($pageSize: Int!, $cursor: String, $filter: InitiativeFilter) {
+ initiatives(first: $pageSize, after: $cursor, orderBy: updatedAt, filter: $filter) {
+ nodes {
+ id
+ name
+ description
+ content
+ slugId
+ status
+ health
+ priority
+ sortOrder
+ icon
+ color
+ url
+ targetDate
+ targetDateResolution
+ startedAt
+ completedAt
+ healthUpdatedAt
+ trashed
+ createdAt
+ updatedAt
+ archivedAt
+ creator { id name email }
+ owner { id name email }
+ parentInitiative { id name }
+ }
+ pageInfo { hasNextPage endCursor }
+ }
+}"""
+
+TEAM_MEMBERSHIPS_QUERY = """
+query PaginatedTeamMemberships($pageSize: Int!, $cursor: String) {
+ teamMemberships(first: $pageSize, after: $cursor) {
+ nodes {
+ id
+ owner
+ sortOrder
+ createdAt
+ updatedAt
+ archivedAt
+ team { id name key }
+ user { id name email }
+ }
+ pageInfo { hasNextPage endCursor }
+ }
+}"""
+
+ISSUE_RELATIONS_QUERY = """
+query PaginatedIssueRelations($pageSize: Int!, $cursor: String) {
+ issueRelations(first: $pageSize, after: $cursor) {
+ nodes {
+ id
+ type
+ createdAt
+ updatedAt
+ archivedAt
+ issue { id identifier }
+ relatedIssue { id identifier }
+ }
+ pageInfo { hasNextPage endCursor }
+ }
+}"""
+
+PROJECT_UPDATES_QUERY = """
+query PaginatedProjectUpdates($pageSize: Int!, $cursor: String, $filter: ProjectUpdateFilter) {
+ projectUpdates(first: $pageSize, after: $cursor, orderBy: updatedAt, filter: $filter) {
+ nodes {
+ id
+ body
+ health
+ url
+ slugId
+ commentCount
+ isStale
+ isDiffHidden
+ diffMarkdown
+ editedAt
+ createdAt
+ updatedAt
+ archivedAt
+ project { id name }
+ user { id name email }
+ }
+ pageInfo { hasNextPage endCursor }
+ }
+}"""
+
+DOCUMENTS_QUERY = """
+query PaginatedDocuments($pageSize: Int!, $cursor: String, $filter: DocumentFilter) {
+ documents(first: $pageSize, after: $cursor, orderBy: updatedAt, filter: $filter) {
+ nodes {
+ id
+ title
+ content
+ icon
+ color
+ slugId
+ url
+ trashed
+ hiddenAt
+ createdAt
+ updatedAt
+ archivedAt
+ creator { id name email }
+ updatedBy { id name email }
+ project { id name }
+ initiative { id name }
+ issue { id identifier }
+ }
+ pageInfo { hasNextPage endCursor }
+ }
+}"""
+
VIEWER_QUERY = "{ viewer { id } }"
QUERIES: dict[str, str] = {
@@ -178,4 +334,11 @@ QUERIES: dict[str, str] = {
"labels": LABELS_QUERY,
"cycles": CYCLES_QUERY,
"resources": RESOURCES_QUERY,
+ "workflow_states": WORKFLOW_STATES_QUERY,
+ "project_milestones": PROJECT_MILESTONES_QUERY,
+ "initiatives": INITIATIVES_QUERY,
+ "team_memberships": TEAM_MEMBERSHIPS_QUERY,
+ "issue_relations": ISSUE_RELATIONS_QUERY,
+ "project_updates": PROJECT_UPDATES_QUERY,
+ "documents": DOCUMENTS_QUERY,
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/settings.py
index beb5ad272c1a..4ab7b8d80ff7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/settings.py
@@ -33,6 +33,7 @@ class LinearEndpointConfig:
partition_mode: PartitionMode | None = "datetime"
partition_format: PartitionFormat | None = "week"
partition_keys: list[str] | None = field(default_factory=lambda: [CREATED_AT])
+ should_sync_default: bool = True
LINEAR_ENDPOINTS: dict[str, LinearEndpointConfig] = {
@@ -71,6 +72,49 @@ LINEAR_ENDPOINTS: dict[str, LinearEndpointConfig] = {
graphql_query_name="attachments",
incremental_fields=INCREMENTAL_DATETIME_FIELDS,
),
+ "workflow_states": LinearEndpointConfig(
+ graphql_query_name="workflowStates",
+ incremental_fields=INCREMENTAL_DATETIME_FIELDS,
+ partition_mode=None,
+ partition_format=None,
+ partition_keys=None,
+ ),
+ "project_milestones": LinearEndpointConfig(
+ graphql_query_name="projectMilestones",
+ incremental_fields=INCREMENTAL_DATETIME_FIELDS,
+ partition_mode=None,
+ partition_format=None,
+ partition_keys=None,
+ ),
+ # Initiatives are only available on Linear's higher-tier plans, so most workspaces have
+ # nothing to sync here — leave it off by default and let those who use them opt in.
+ "initiatives": LinearEndpointConfig(
+ incremental_fields=INCREMENTAL_DATETIME_FIELDS,
+ partition_mode=None,
+ partition_format=None,
+ partition_keys=None,
+ should_sync_default=False,
+ ),
+ "team_memberships": LinearEndpointConfig(
+ graphql_query_name="teamMemberships",
+ incremental_fields=[],
+ partition_mode=None,
+ partition_format=None,
+ partition_keys=None,
+ ),
+ # `issueRelations` takes no filter argument, so there is no server-side timestamp filter
+ # to drive an incremental sync — full refresh only.
+ "issue_relations": LinearEndpointConfig(
+ graphql_query_name="issueRelations",
+ incremental_fields=[],
+ ),
+ "project_updates": LinearEndpointConfig(
+ graphql_query_name="projectUpdates",
+ incremental_fields=INCREMENTAL_DATETIME_FIELDS,
+ ),
+ "documents": LinearEndpointConfig(
+ incremental_fields=INCREMENTAL_DATETIME_FIELDS,
+ ),
}
ENDPOINTS = tuple(LINEAR_ENDPOINTS.keys())
@@ -78,3 +122,5 @@ ENDPOINTS = tuple(LINEAR_ENDPOINTS.keys())
INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
name: config.incremental_fields for name, config in LINEAR_ENDPOINTS.items()
}
+
+SHOULD_SYNC_DEFAULT: dict[str, bool] = {name: config.should_sync_default for name, config in LINEAR_ENDPOINTS.items()}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/source.py
index 252995470a41..00cc1d6ea69e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/source.py
@@ -17,7 +17,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.can
from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import OAuthMixin
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (
+ SourceSchema,
+ build_endpoint_schemas,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.linear import LinearSourceConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.linear.linear import (
@@ -28,6 +31,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.linear.lin
from products.warehouse_sources.backend.temporal.data_imports.sources.linear.settings import (
ENDPOINTS,
INCREMENTAL_FIELDS,
+ SHOULD_SYNC_DEFAULT,
)
from products.warehouse_sources.backend.types import ExternalDataSourceType
@@ -104,19 +108,12 @@ class LinearSource(ResumableSource[LinearSourceConfig, LinearResumeConfig], OAut
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
- schemas = [
- SourceSchema(
- name=endpoint,
- supports_incremental=bool(INCREMENTAL_FIELDS.get(endpoint)),
- supports_append=bool(INCREMENTAL_FIELDS.get(endpoint)),
- incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),
- )
- for endpoint in list(ENDPOINTS)
- ]
- if names is not None:
- names_set = set(names)
- schemas = [s for s in schemas if s.name in names_set]
- return schemas
+ return build_endpoint_schemas(
+ ENDPOINTS,
+ INCREMENTAL_FIELDS,
+ names,
+ should_sync_default=SHOULD_SYNC_DEFAULT,
+ )
def validate_credentials(
self,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.py b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.py
index 3708413f12d4..22837fafd6c5 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/linear/test_linear.py
@@ -1,3 +1,4 @@
+import re
import copy
import json
from collections.abc import Iterable
@@ -11,6 +12,7 @@ from parameterized import parameterized
from tenacity import Future, RetryCallState
from products.warehouse_sources.backend.temporal.data_imports.sources.linear.linear import (
+ _FLOAT_FIELDS,
LINEAR_MAX_RETRY_AFTER_SECONDS,
LINEAR_MAX_RETRY_ATTEMPTS,
LinearResumeConfig,
@@ -20,9 +22,20 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.linear.lin
_wait_strategy,
linear_source,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.linear.queries import QUERIES
+from products.warehouse_sources.backend.temporal.data_imports.sources.linear.settings import (
+ ENDPOINTS,
+ INCREMENTAL_FIELDS,
+ LINEAR_ENDPOINTS,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.linear.source import LinearSource
+def _graphql_query_name(endpoint_name: str) -> str:
+ config = LINEAR_ENDPOINTS[endpoint_name]
+ return config.graphql_query_name or endpoint_name
+
+
def _make_response(nodes: list[dict[str, Any]], has_next_page: bool, end_cursor: str | None) -> MagicMock:
response = MagicMock()
response.status_code = 200
@@ -444,17 +457,23 @@ class TestMakePaginatedRequest:
class TestFloatFieldCoercion:
- @parameterized.expand([("cycles",), ("projects",)])
+ @parameterized.expand(
+ [(endpoint, field) for endpoint, fields in _FLOAT_FIELDS.items() for field in fields],
+ name_func=lambda func, _num, param: f"{func.__name__}_{param.args[0]}_{param.args[1]}",
+ )
@patch("products.warehouse_sources.backend.temporal.data_imports.sources.linear.linear.make_tracked_session")
- def test_whole_number_progress_is_coerced_to_float(self, endpoint_name: str, mock_session_cls: MagicMock) -> None:
- # Whole progress values (0, 1) arrive as JSON ints. Left as ints, a table-creating batch of
- # only whole values infers int64 and the first fractional progress wedges the sync with
- # ArrowInvalid. The source must yield floats so the column always infers as float64.
+ def test_whole_number_float_field_is_coerced_to_float(
+ self, endpoint_name: str, field_name: str, mock_session_cls: MagicMock
+ ) -> None:
+ # Whole values (0, 1) of Linear's Float fields arrive as JSON ints. Left as ints, a
+ # table-creating batch of only whole values infers int64 and the first fractional value
+ # wedges the sync with ArrowInvalid. The source must yield floats so the column always
+ # infers as float64.
session = MagicMock()
session.post.side_effect = [
_make_response_for(
- endpoint_name,
- [{"id": "a", "progress": 0}, {"id": "b", "progress": 1}, {"id": "c", "progress": None}],
+ _graphql_query_name(endpoint_name),
+ [{"id": "a", field_name: 0}, {"id": "b", field_name: 1}, {"id": "c", field_name: None}],
)
]
mock_session_cls.return_value = session
@@ -468,9 +487,67 @@ class TestFloatFieldCoercion:
)
)
- progress_values = [node["progress"] for node in pages[0]]
- assert progress_values == [0.0, 1.0, None]
- assert all(isinstance(v, float) for v in progress_values if v is not None)
+ values = [node[field_name] for node in pages[0]]
+ assert values == [0.0, 1.0, None]
+ assert all(isinstance(v, float) for v in values if v is not None)
+
+
+class TestEndpointCatalog:
+ @parameterized.expand([(name,) for name in ENDPOINTS])
+ def test_query_root_field_matches_declared_graphql_query_name(self, endpoint_name: str) -> None:
+ # The paginator reads payload["data"][graphql_query_name]. If the catalog's query name
+ # drifts from the root field the query actually asks for, every page raises KeyError.
+ query = QUERIES[endpoint_name]
+ root_field = re.search(r"\)\s*\{\s*\n\s*(\w+)\(", query)
+ assert root_field is not None, f"could not find a root field in the {endpoint_name} query"
+ assert root_field.group(1) == _graphql_query_name(endpoint_name)
+
+ @parameterized.expand([(name,) for name in ENDPOINTS])
+ def test_filter_variable_is_declared_exactly_when_the_endpoint_is_incremental(self, endpoint_name: str) -> None:
+ # The incremental cutoff rides in a $filter variable. Linear ignores variables a query
+ # doesn't declare, so an incremental endpoint whose query omits $filter silently re-reads
+ # the whole collection on every sync instead of failing.
+ declares_filter = "$filter" in QUERIES[endpoint_name]
+ assert declares_filter == bool(INCREMENTAL_FIELDS[endpoint_name])
+
+ @parameterized.expand([(name,) for name in ENDPOINTS])
+ def test_query_selects_primary_key_and_partition_keys(self, endpoint_name: str) -> None:
+ # A primary key or partition key that the query never selects lands as a missing column:
+ # merges stop deduping and partitioning silently degrades.
+ config = LINEAR_ENDPOINTS[endpoint_name]
+ query = QUERIES[endpoint_name]
+ for required in [config.primary_key, *(config.partition_keys or [])]:
+ assert re.search(rf"^\s*{required}\s*$", query, re.MULTILINE), (
+ f"{endpoint_name} query does not select {required}"
+ )
+
+
+class TestGetSchemas:
+ def test_reports_every_endpoint_with_its_sync_capabilities(self) -> None:
+ schemas = {s.name: s for s in LinearSource().get_schemas(cast(Any, None), team_id=1)}
+
+ assert set(schemas) == set(ENDPOINTS)
+ # Only endpoints whose Linear query takes a server-side updatedAt filter may sync
+ # incrementally; the rest must stay full refresh.
+ assert {name for name, s in schemas.items() if s.supports_incremental} == {
+ "issues",
+ "projects",
+ "comments",
+ "cycles",
+ "resources",
+ "workflow_states",
+ "project_milestones",
+ "initiatives",
+ "project_updates",
+ "documents",
+ }
+ # Initiatives are plan-gated, so they must not be enabled for every new connection.
+ assert {name for name, s in schemas.items() if not s.should_sync_default} == {"initiatives"}
+
+ def test_names_filter_narrows_the_schema_list(self) -> None:
+ schemas = LinearSource().get_schemas(cast(Any, None), team_id=1, names=["workflow_states"])
+
+ assert [s.name for s in schemas] == ["workflow_states"]
class TestRateLimitBackoff: