: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(data-warehouse): add Aha! Ideas source (#73180)
Tom Owers14eb5709c8f2
diff --git a/frontend/public/services/aha_ideas.png b/frontend/public/services/aha_ideas.pngindex 8d0e0c0fd4ae..1700317f59d9 100644Binary files a/frontend/public/services/aha_ideas.png and b/frontend/public/services/aha_ideas.png differdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.mdindex 7f94661f4fec..e567dcd79b93 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md@@ -52,6 +52,7 @@ the row lists both.| adroll | HTTP | requests | ✅ || agilecrm | HTTP | requests | ✅ || aha | HTTP | requests | ✅ |+| aha_ideas | HTTP | requests + `rest_source.RESTClient` | ✅ || airbrake | HTTP | requests | ✅ || aircall | HTTP | requests | ✅ || airops | HTTP | requests | ✅ |@@ -699,7 +700,6 @@ doesn't conflict with concurrent PRs.- adp_workforce_now- adyen- aftership-- aha_ideas- ahrefs- aikido_security- airbytediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.pynew file mode 100644index 000000000000..1e54997bd2f2--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.py@@ -0,0 +1,269 @@+import re+import dataclasses+from collections.abc import Iterable+from datetime import UTC, date, datetime+from typing import Any, Optional, cast++from requests import Response++from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.settings import (+ AHA_IDEAS_ENDPOINTS,+ AhaIdeasEndpointConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (+ RESTAPIConfig,+ rest_api_resource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ build_dependent_resource,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.jsonpath_utils import (+ find_values,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (+ PageNumberPaginator,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfig+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager+from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe++AHA_API_PATH = "/api/v1"++# A single DNS label: letters, digits, hyphens. Rejects anything that could retarget the host+# (slashes, `@`, dots) so the stored API key is only ever sent to `<subdomain>.aha.io`.+_SUBDOMAIN_RE = re.compile(r"^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?$")+++class AhaIdeasResumeConfig:+ # Next 1-indexed page to fetch. None means "start from page 1". Only populated for top-level+ # (non fan-out) endpoints — dependent-resource fan-out (idea_comments) doesn't expose a resume+ # hook in the rest_source framework, so it always restarts from page 1 of its parent.+ next_page: int | None = None+++def normalize_subdomain(subdomain: str) -> str:+ """Reduce user input to a bare, validated Aha! subdomain label.++ Accepts either the full host (``yourcompany.aha.io``) or the bare subdomain+ (``yourcompany``). Raises ``ValueError`` on anything that isn't a single DNS label so the+ API key can never be retargeted away from ``<subdomain>.aha.io``.+ """+ cleaned = subdomain.strip().removeprefix("https://").removeprefix("http://")+ cleaned = cleaned.strip("/")+ cleaned = cleaned.removesuffix(".aha.io")+ if not _SUBDOMAIN_RE.match(cleaned):+ raise ValueError(+ f"Invalid Aha! account domain: {subdomain!r}. Enter just your subdomain, e.g. 'yourcompany' "+ "for yourcompany.aha.io."+ )+ return cleaned+++def _base_url(subdomain: str) -> str:+ return f"https://{normalize_subdomain(subdomain)}.aha.io{AHA_API_PATH}"+++def _format_updated_since(value: Any) -> str:+ """Format an incremental cursor as the ISO8601 UTC string Aha! expects for `updated_since`."""+ if isinstance(value, datetime):+ aware = value if value.tzinfo is not None else value.replace(tzinfo=UTC)+ return aware.astimezone(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")+ if isinstance(value, date):+ return datetime.combine(value, datetime.min.time(), tzinfo=UTC).strftime("%Y-%m-%dT%H:%M:%SZ")+ return str(value)+++def _build_initial_params(+ config: AhaIdeasEndpointConfig,+ should_use_incremental_field: bool,+ db_incremental_field_last_value: Any,+) -> dict[str, Any]:+ params: dict[str, Any] = {"per_page": config.page_size}+ # Only Aha!'s `updated_since`-capable endpoints filter server-side; everything else is full refresh.+ if config.supports_incremental and should_use_incremental_field and db_incremental_field_last_value:+ params["updated_since"] = _format_updated_since(db_incremental_field_last_value)+ return params+++class AhaIdeasPageNumberPaginator(PageNumberPaginator):+ """Page-number pagination with Aha!'s full-page fallback.++ Aha! reports `pagination.total_pages` (total number of PAGES), which the base paginator uses+ to stop after the last page. If that metadata is ever absent, fall back to the full-page+ heuristic: a short page means there are no more pages.+ """++ def __init__(self, page_size: int) -> None:+ super().__init__(base_page=1, page_param="page", total_path="pagination.total_pages")+ self._page_size = page_size++ def update_state(self, response: Response, data: Optional[list[Any]] = None) -> None:+ super().update_state(response, data)+ if not self._has_next_page or data is None:+ return+ try:+ values = find_values(self.total_path, response.json()) if self.total_path else []+ except Exception:+ values = []+ has_total_metadata = bool(values) and isinstance(values[0], int)+ if not has_total_metadata and len(data) < self._page_size:+ self._has_next_page = False+++def _client_config(subdomain: str, api_key: str, page_size: int) -> ClientConfig:+ return {+ "base_url": _base_url(subdomain),+ # Auth (Bearer) goes through the framework auth config so its value is redacted from+ # logs; only the non-secret accept header is set here.+ "headers": {"Accept": "application/json"},+ "auth": {"type": "bearer", "token": api_key},+ "paginator": AhaIdeasPageNumberPaginator(page_size=page_size),+ }+++def _non_fanout_source(+ subdomain: str,+ api_key: str,+ endpoint: str,+ team_id: int,+ job_id: str,+ resumable_source_manager: ResumableSourceManager[AhaIdeasResumeConfig],+ should_use_incremental_field: bool,+ db_incremental_field_last_value: Optional[Any],+) -> SourceResponse:+ config = AHA_IDEAS_ENDPOINTS[endpoint]+ params = _build_initial_params(config, should_use_incremental_field, db_incremental_field_last_value)++ rest_config: RESTAPIConfig = {+ "client": _client_config(subdomain, api_key, config.page_size),+ "resource_defaults": {},+ "resources": [+ {+ "name": endpoint,+ "endpoint": {+ "path": config.path,+ "params": params,+ # A 200 body without the root key yields an empty page and ends pagination.+ "data_selector": config.response_key,+ },+ }+ ],+ }++ initial_paginator_state: Optional[dict[str, Any]] = None+ if resumable_source_manager.can_resume():+ resume = resumable_source_manager.load_state()+ if resume is not None and resume.next_page:+ initial_paginator_state = {"page": resume.next_page}++ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:+ # Persist only when a next page remains; save AFTER a page is yielded so a crash re-yields+ # the last page (merge dedupes) rather than skipping it.+ if state and state.get("page") is not None:+ resumable_source_manager.save_state(AhaIdeasResumeConfig(next_page=int(state["page"])))++ resource = rest_api_resource(+ rest_config,+ team_id,+ job_id,+ db_incremental_field_last_value,+ resume_hook=save_checkpoint,+ initial_paginator_state=initial_paginator_state,+ )++ return SourceResponse(+ name=endpoint,+ items=lambda: resource,+ primary_keys=config.primary_keys,+ partition_count=1,+ partition_size=1,+ partition_mode="datetime" if config.partition_key else None,+ partition_format="month" if config.partition_key else None,+ partition_keys=[config.partition_key] if config.partition_key else None,+ column_hints=resource.column_hints,+ )+++def _fanout_source(+ subdomain: str,+ api_key: str,+ endpoint: str,+ team_id: int,+ job_id: str,+) -> SourceResponse:+ config = AHA_IDEAS_ENDPOINTS[endpoint]+ assert config.fanout is not None++ dependent_resource = cast(+ Iterable[Any],+ build_dependent_resource(+ endpoint_configs=AHA_IDEAS_ENDPOINTS,+ child_endpoint=endpoint,+ fanout=config.fanout,+ client_config=_client_config(subdomain, api_key, config.page_size),+ path_format_values={},+ team_id=team_id,+ job_id=job_id,+ # idea_comments has no server-side timestamp filter, so this fan-out is always full+ # refresh — the watermark is never consulted.+ db_incremental_field_last_value=None,+ should_use_incremental_field=False,+ page_size_param="per_page",+ parent_endpoint_extra={"data_selector": AHA_IDEAS_ENDPOINTS[config.fanout.parent_name].response_key},+ child_endpoint_extra={"data_selector": config.response_key},+ ),+ )++ return SourceResponse(+ name=endpoint,+ items=lambda: dependent_resource,+ primary_keys=config.primary_keys,+ partition_count=1,+ partition_size=1,+ partition_mode="datetime" if config.partition_key else None,+ partition_format="month" if config.partition_key else None,+ partition_keys=[config.partition_key] if config.partition_key else None,+ )+++def aha_ideas_source(+ subdomain: str,+ api_key: str,+ endpoint: str,+ team_id: int,+ job_id: str,+ resumable_source_manager: ResumableSourceManager[AhaIdeasResumeConfig],+ should_use_incremental_field: bool = False,+ db_incremental_field_last_value: Optional[Any] = None,+) -> SourceResponse:+ config = AHA_IDEAS_ENDPOINTS[endpoint]+ if config.fanout is not None:+ return _fanout_source(subdomain, api_key, endpoint, team_id, job_id)++ return _non_fanout_source(+ subdomain,+ api_key,+ endpoint,+ team_id,+ job_id,+ resumable_source_manager,+ should_use_incremental_field,+ db_incremental_field_last_value,+ )+++def validate_credentials(subdomain: str, api_key: str) -> tuple[bool, int | None]:+ """Probe Aha!'s `/me` endpoint to confirm the token is genuine.++ Returns ``(ok, status_code)``. ``status_code`` is ``None`` on a transport error. Raises+ ``ValueError`` if the subdomain is malformed so the caller can surface a precise message.+ """+ url = f"{_base_url(subdomain)}/me"+ return validate_via_probe(+ lambda: make_tracked_session(redact_values=(api_key,)),+ url,+ headers={"Authorization": f"Bearer {api_key}", "Accept": "application/json"},+ )diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/canonical_descriptions.pynew file mode 100644index 000000000000..9832605c04e1--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/canonical_descriptions.py@@ -0,0 +1,99 @@+"""Canonical, documentation-sourced descriptions for Aha! Ideas endpoints and columns.++Sourced from the official Aha! API reference (https://www.aha.io/api/resources/ideas). Keyed by the+endpoint names in `settings.py` `AHA_IDEAS_ENDPOINTS`, which match the `ExternalDataSchema.name` of a+synced Aha! Ideas table. Columns absent here fall back to LLM enrichment.+"""++from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)++CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {+ "ideas": {+ "description": "An idea submitted to your Aha! Ideas portal — feedback that can be promoted into features.",+ "docs_url": "https://www.aha.io/api/resources/ideas/list_ideas",+ "columns": {+ "id": "Unique identifier for the idea.",+ "name": "The idea's name.",+ "reference_num": "Human-readable reference number (e.g. PRJ1-I-1).",+ "created_at": "Time at which the idea was created.",+ "updated_at": "Time at which the idea was last updated.",+ "workflow_status": "The idea's current status in its workflow.",+ "url": "URL of the idea in the Aha! web app.",+ "resource": "API URL of the idea.",+ },+ },+ "idea_portals": {+ "description": "An Aha! Ideas portal — a public or private site where users submit and vote on ideas.",+ "docs_url": "https://www.aha.io/api/resources/idea_portals/list_all_idea_portals_in_an_account",+ "columns": {+ "id": "Unique identifier for the idea portal.",+ "title": "The portal's display name.",+ "portal_enabled": "Whether the portal is currently enabled.",+ "access_type": "Who can access the portal (e.g. public, submit-only).",+ "external_url": "Public URL of the portal.",+ "created_at": "Time at which the portal was created.",+ },+ },+ "idea_organizations": {+ "description": "A submitting organization associated with idea votes — typically a customer account.",+ "docs_url": "https://www.aha.io/api/resources/idea_organizations/list_idea_organizations",+ "columns": {+ "id": "Unique identifier for the idea organization.",+ "name": "The organization's name.",+ "created_at": "Time at which the organization was created.",+ "url": "URL of the organization in the Aha! web app.",+ "resource": "API URL of the organization.",+ },+ },+ "idea_users": {+ "description": "An external user who has submitted ideas or votes to your Aha! Ideas portals.",+ "docs_url": "https://www.aha.io/api/resources/idea_users/list_idea_users_for_an_account",+ "columns": {+ "id": "Unique identifier for the idea user.",+ "name": "The idea user's full name.",+ "email": "The idea user's email address.",+ "created_at": "Time at which the idea user was created.",+ },+ },+ "idea_themes": {+ "description": "A theme grouping related ideas together by topic.",+ "docs_url": "https://www.aha.io/api/resources/idea_themes/list_idea_themes",+ "columns": {+ "id": "Unique identifier for the theme.",+ "reference_num": "Human-readable reference number for the theme.",+ "name": "The theme's name.",+ "created_at": "Time at which the theme was created.",+ },+ },+ "idea_endorsements": {+ "description": "A vote (endorsement) cast for an idea, optionally by a portal user and/or organization.",+ "docs_url": "https://www.aha.io/api/resources/idea_votes/list_votes_for_an_account",+ "columns": {+ "id": "Unique identifier for the vote.",+ "idea_id": "Identifier of the idea this vote was cast for.",+ "created_at": "Time at which the vote was created.",+ "updated_at": "Time at which the vote was last updated.",+ "value": "Custom point value assigned to the vote, if any.",+ "weight": "Number of votes this record counts as (proxy votes can count for more than one).",+ "endorsed_by_portal_user": "The ideas portal user who cast the vote, if submitted via a portal.",+ "endorsed_by_idea_user": "The idea user who cast the vote.",+ "idea_organization": "The organization the voter belongs to, if any.",+ },+ },+ "idea_comments": {+ "description": "A comment left on an idea, by either an internal Aha! user or an ideas portal user.",+ "docs_url": "https://www.aha.io/api/resources/idea_comments/list_idea_comments_for_an_idea",+ "columns": {+ "id": "Unique identifier for the comment.",+ "idea_id": "Identifier of the idea this comment was left on.",+ "body": "The comment's text content.",+ "created_at": "Time at which the comment was created.",+ "updated_at": "Time at which the comment was last updated.",+ "visibility": "Who can see the comment (e.g. visible to all ideas portal users).",+ "parent_idea_comment_id": "Identifier of the parent comment, if this is a reply.",+ "idea_commenter_user": "The user who wrote the comment.",+ },+ },+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.pynew file mode 100644index 000000000000..002820af1a37--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.py@@ -0,0 +1,116 @@+from dataclasses import dataclass, field+from typing import Optional++from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ DependentEndpointConfig,+)+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType++# Aha! caps `per_page` at 200 (default 30). Always request the max to minimise round trips.+PER_PAGE = 200+++def _updated_at_incremental_fields() -> list[IncrementalField]:+ # Every incremental-capable Aha! Ideas endpoint filters server-side with `updated_since`,+ # which keys off `updated_at`. Advertising just `updated_at` keeps the user's chosen cursor+ # aligned with what the API actually filters on.+ return [+ {+ "label": "updated_at",+ "type": IncrementalFieldType.DateTime,+ "field": "updated_at",+ "field_type": IncrementalFieldType.DateTime,+ },+ ]+++@dataclass+class AhaIdeasEndpointConfig:+ name: str+ path: str # Path under /api/v1, e.g. "/ideas"+ # Root key of the list in the JSON response. Usually equals `path` minus the slash, but+ # `/ideas/endorsements` exposes idea votes under an `idea_endorsements` root key.+ response_key: str+ # Aha! exposes `updated_since` (filters by `updated_at`) on this endpoint's list action.+ supports_incremental: bool+ # Stable creation-time field to partition by. None when the resource has no reliable created_at.+ partition_key: Optional[str] = "created_at"+ incremental_fields: list[IncrementalField] = field(default_factory=list)+ default_incremental_field: str | None = None+ primary_keys: list[str] = field(default_factory=lambda: ["id"])+ should_sync_default: bool = True+ page_size: int = PER_PAGE+ fanout: DependentEndpointConfig | None = None+++AHA_IDEAS_ENDPOINTS: dict[str, AhaIdeasEndpointConfig] = {+ "ideas": AhaIdeasEndpointConfig(+ name="ideas",+ path="/ideas",+ response_key="ideas",+ supports_incremental=True,+ incremental_fields=_updated_at_incremental_fields(),+ ),+ "idea_portals": AhaIdeasEndpointConfig(+ name="idea_portals",+ path="/idea_portals",+ response_key="idea_portals",+ # "List all idea portals in an account" documents only `page`/`per_page` — no+ # `updated_since` filter — so this stays full refresh.+ supports_incremental=False,+ ),+ "idea_organizations": AhaIdeasEndpointConfig(+ name="idea_organizations",+ path="/idea_organizations",+ response_key="idea_organizations",+ supports_incremental=True,+ incremental_fields=_updated_at_incremental_fields(),+ ),+ "idea_users": AhaIdeasEndpointConfig(+ name="idea_users",+ path="/idea_users",+ response_key="idea_users",+ supports_incremental=True,+ incremental_fields=_updated_at_incremental_fields(),+ ),+ "idea_themes": AhaIdeasEndpointConfig(+ name="idea_themes",+ path="/idea_themes",+ response_key="idea_themes",+ # "List idea themes" documents only `page`/`per_page` — no `updated_since` filter.+ supports_incremental=False,+ ),+ "idea_endorsements": AhaIdeasEndpointConfig(+ name="idea_endorsements",+ path="/ideas/endorsements",+ response_key="idea_endorsements",+ supports_incremental=True,+ incremental_fields=_updated_at_incremental_fields(),+ ),+ "idea_comments": AhaIdeasEndpointConfig(+ name="idea_comments",+ path="/ideas/{idea_id}/idea_comments",+ response_key="idea_comments",+ # "List idea comments for an idea" documents only `page`/`per_page`/`idea_id` — no+ # `updated_since` filter.+ supports_incremental=False,+ # Aha!'s comment ids already look globally unique, but the parent idea id is included+ # defensively since this table aggregates comments fanned out across every idea and the+ # docs don't explicitly state global uniqueness.+ primary_keys=["id", "idea_id"],+ fanout=DependentEndpointConfig(+ parent_name="ideas",+ resolve_param="idea_id",+ resolve_field="id",+ # The idea_comments response already includes `idea_id` on every row natively, so no+ # parent fields need to be injected.+ include_from_parent=[],+ ),+ ),+}++ENDPOINTS = tuple(AHA_IDEAS_ENDPOINTS.keys())++INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {+ name: config.incremental_fields for name, config in AHA_IDEAS_ENDPOINTS.items()+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/source.pyindex e943a4ca889b..2962077f4735 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/source.py@@ -1,13 +1,37 @@-from typing import cast+from typing import Optional, castfrom posthog.schema import (DataWarehouseSourceCategory,ExternalDataSourceType as SchemaExternalDataSourceType,+ ReleaseStatus,SourceConfig,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (+ SourceInputs,+ SourceResponse,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.aha_ideas import (+ AhaIdeasResumeConfig,+ aha_ideas_source,+ validate_credentials as validate_aha_ideas_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.settings import (+ ENDPOINTS,+ INCREMENTAL_FIELDS,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)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,+ build_endpoint_schemas,+)from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.ahaideas import (AhaIdeasSourceConfig,)@@ -15,18 +39,123 @@ from products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.register-class AhaIdeasSource(SimpleSource[AhaIdeasSourceConfig]):+class AhaIdeasSource(ResumableSource[AhaIdeasSourceConfig, AhaIdeasResumeConfig]):+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs++ supported_versions = ("v1",)+ default_version = "v1"+ api_docs_url = "https://www.aha.io/api/resources/ideas"+@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.AHAIDEAS+ @property+ def connection_host_fields(self) -> list[str]:+ # The API key is sent to `<subdomain>.aha.io`, so changing the subdomain must re-require it.+ return ["subdomain"]+@propertydef get_source_config(self) -> SourceConfig:return SourceConfig(name=SchemaExternalDataSourceType.AHA_IDEAS,category=DataWarehouseSourceCategory.PRODUCTIVITY,- label="Aha! (Aha! Labs Inc.)",+ label="Aha! Ideas",+ releaseStatus=ReleaseStatus.ALPHA,+ caption="""Enter your Aha! account domain and API key to pull your Aha! Ideas portal data — ideas, votes, comments, submitters, and portals — into the PostHog Data warehouse.++Create an API key under **Settings → Personal → Developer → API keys** in your Aha! account. The key inherits your account permissions, so it can read every record you can see.""",iconPath="/static/services/aha_ideas.png",- fields=cast(list[FieldType], []),- unreleasedSource=True,+ docsUrl="https://posthog.com/docs/cdp/sources/aha-ideas",+ fields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="subdomain",+ label="Account domain",+ type=SourceFieldInputConfigType.TEXT,+ required=True,+ placeholder="yourcompany",+ secret=False,+ ),+ SourceFieldInputConfig(+ name="api_key",+ label="API key",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="",+ secret=True,+ ),+ ],+ ),+ )++ def get_canonical_descriptions(self) -> CanonicalDescriptions:+ from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.canonical_descriptions import (+ CANONICAL_DESCRIPTIONS,+ )++ return CANONICAL_DESCRIPTIONS++ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {+ # 401/403 surface as a requests HTTPError when the REST client calls `raise_for_status()`.+ # Retrying can never fix a credential/permission problem, so fail the sync. Match the+ # stable status text, not the per-request path.+ "401 Client Error: Unauthorized": "Your Aha! API key is invalid or has been revoked. Create a new key in your Aha! account settings, then reconnect.",+ "403 Client Error: Forbidden": "Your Aha! API key is missing the permissions needed to sync this data. Check the key's account permissions, then reconnect.",+ }++ def get_schemas(+ self,+ config: AhaIdeasSourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ api_version: str | None = None,+ ) -> list[SourceSchema]:+ # `build_endpoint_schemas` treats any endpoint present in the mapping as incremental, so+ # drop the full-refresh endpoints (empty `incremental_fields`) to keep them full refresh.+ incremental_fields = {name: fields for name, fields in INCREMENTAL_FIELDS.items() if fields}+ return build_endpoint_schemas(ENDPOINTS, incremental_fields, names)++ def validate_credentials(+ self,+ config: AhaIdeasSourceConfig,+ team_id: int,+ schema_name: Optional[str] = None,+ api_version: str | None = None,+ ) -> tuple[bool, str | None]:+ try:+ ok, status_code = validate_aha_ideas_credentials(config.subdomain, config.api_key)+ except ValueError as e:+ return False, str(e)++ if ok:+ return True, None+ if status_code == 401:+ return False, "Invalid Aha! API key"+ return False, "Could not connect to Aha! with the provided account domain and API key"++ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[AhaIdeasResumeConfig]:+ return ResumableSourceManager[AhaIdeasResumeConfig](inputs, AhaIdeasResumeConfig)++ def source_for_pipeline(+ self,+ config: AhaIdeasSourceConfig,+ resumable_source_manager: ResumableSourceManager[AhaIdeasResumeConfig],+ inputs: SourceInputs,+ ) -> SourceResponse:+ return aha_ideas_source(+ subdomain=config.subdomain,+ api_key=config.api_key,+ endpoint=inputs.schema_name,+ team_id=inputs.team_id,+ job_id=inputs.job_id,+ resumable_source_manager=resumable_source_manager,+ should_use_incremental_field=inputs.should_use_incremental_field,+ db_incremental_field_last_value=inputs.db_incremental_field_last_value+ if inputs.should_use_incremental_field+ else None,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas.pynew file mode 100644index 000000000000..3dc69bf1fab4--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas.py@@ -0,0 +1,389 @@+import json+from datetime import UTC, date, datetime+from typing import Any, cast++import pytest+from unittest import mock++from parameterized import parameterized+from requests import Response++from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.aha_ideas import (+ AhaIdeasResumeConfig,+ _build_initial_params,+ _format_updated_since,+ aha_ideas_source,+ normalize_subdomain,+ validate_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.settings import (+ AHA_IDEAS_ENDPOINTS,+ PER_PAGE,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import BearerTokenAuth++# RESTClient builds its session via make_tracked_session in the rest_client module.+CLIENT_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client.make_tracked_session"+# validate_credentials builds its own tracked session in the aha_ideas module.+AHA_IDEAS_SESSION_PATCH = (+ "products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.aha_ideas.make_tracked_session"+)+++class _FakeDltResource:+ def __init__(self, name: str, rows: list[dict]) -> None:+ self.name = name+ self._rows = rows++ def add_map(self, mapper):+ self._rows = [mapper(dict(row)) for row in self._rows]+ return self++ def __iter__(self):+ return iter(self._rows)+++class TestNormalizeSubdomain:+ @parameterized.expand(+ [+ ("bare", "acme", "acme"),+ ("full_host", "acme.aha.io", "acme"),+ ("https_url", "https://acme.aha.io", "acme"),+ ("trailing_slash", "acme.aha.io/", "acme"),+ ("with_hyphen", "acme-corp", "acme-corp"),+ ("whitespace", " acme ", "acme"),+ ]+ )+ def test_valid_subdomains(self, _name: str, value: str, expected: str) -> None:+ assert normalize_subdomain(value) == expected++ @parameterized.expand(+ [+ ("path_injection", "acme/../evil"),+ ("host_injection", "acme.evil.com"),+ ("userinfo_injection", "[email protected]"),+ ("empty", ""),+ ("space_inside", "ac me"),+ ("trailing_hyphen", "acme-"),+ ]+ )+ def test_invalid_subdomains_raise(self, _name: str, value: str) -> None:+ with pytest.raises(ValueError):+ normalize_subdomain(value)+++class TestFormatUpdatedSince:+ @parameterized.expand(+ [+ ("utc_datetime", datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC), "2026-03-04T02:58:14Z"),+ ("naive_datetime", datetime(2026, 3, 4, 2, 58, 14), "2026-03-04T02:58:14Z"),+ ("date_value", date(2026, 3, 4), "2026-03-04T00:00:00Z"),+ ("string_passthrough", "2026-03-04T02:58:14Z", "2026-03-04T02:58:14Z"),+ ]+ )+ def test_format(self, _name: str, value: Any, expected: str) -> None:+ result = _format_updated_since(value)+ assert result == expected+ assert "+00:00" not in result+++class TestBuildInitialParams:+ def test_incremental_endpoint_with_cursor_adds_updated_since(self) -> None:+ params = _build_initial_params(+ AHA_IDEAS_ENDPOINTS["ideas"],+ should_use_incremental_field=True,+ db_incremental_field_last_value=datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC),+ )+ assert params == {"per_page": PER_PAGE, "updated_since": "2026-03-04T02:58:14Z"}++ def test_incremental_endpoint_without_cursor_omits_updated_since(self) -> None:+ params = _build_initial_params(+ AHA_IDEAS_ENDPOINTS["ideas"], should_use_incremental_field=True, db_incremental_field_last_value=None+ )+ assert params == {"per_page": PER_PAGE}++ def test_full_refresh_endpoint_never_filters(self) -> None:+ # idea_portals has no server-side `updated_since`; a cursor must not leak into the request.+ params = _build_initial_params(+ AHA_IDEAS_ENDPOINTS["idea_portals"],+ should_use_incremental_field=True,+ db_incremental_field_last_value=datetime(2026, 3, 4, tzinfo=UTC),+ )+ assert params == {"per_page": PER_PAGE}+++def _response(+ response_key: str,+ items: list[dict[str, Any]] | None,+ *,+ current_page: int | None = None,+ total_pages: int | None = None,+ drop_key: bool = False,+) -> Response:+ body: dict[str, Any] = {}+ if not drop_key:+ body[response_key] = items or []+ if total_pages is not None:+ body["pagination"] = {"current_page": current_page or 1, "total_pages": total_pages}+ resp = Response()+ resp.status_code = 200+ resp._content = json.dumps(body).encode()+ return resp+++def _make_manager(resume_state: AhaIdeasResumeConfig | None = None) -> mock.MagicMock:+ manager = mock.MagicMock()+ manager.can_resume.return_value = resume_state is not None+ manager.load_state.return_value = resume_state+ return manager+++def _wire(session: mock.MagicMock, responses: list[Response]) -> list[dict[str, Any]]:+ """Wire a mock session and return a list that captures each request AT SEND TIME.++ ``request.params`` is a single dict mutated in place across pages, so inspecting it after the+ run shows only the final state — snapshot a copy when each request is prepared instead.+ """+ session.headers = {}+ snapshots: list[dict[str, Any]] = []++ def _prepare(request: Any) -> mock.MagicMock:+ snapshots.append({"url": request.url, "params": dict(request.params or {}), "auth": request.auth})+ return mock.MagicMock()++ session.prepare_request.side_effect = _prepare+ session.send.side_effect = responses+ return snapshots+++def _source(endpoint: str, manager: mock.MagicMock, **kwargs: Any):+ return aha_ideas_source(+ subdomain="acme",+ api_key="key",+ endpoint=endpoint,+ team_id=1,+ job_id="j",+ resumable_source_manager=manager,+ **kwargs,+ )+++def _rows(source_response) -> list[dict[str, Any]]:+ return [row for page in source_response.items() for row in page]+++class TestAhaIdeasSourceNonFanout:+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_paginates_until_total_pages(self, MockSession) -> None:+ session = MockSession.return_value+ snapshots = _wire(+ session,+ [+ _response("ideas", [{"id": "1"}, {"id": "2"}], current_page=1, total_pages=2),+ _response("ideas", [{"id": "3"}], current_page=2, total_pages=2),+ ],+ )++ rows = _rows(_source("ideas", _make_manager()))++ assert [r["id"] for r in rows] == ["1", "2", "3"]+ # total_pages=2 terminates after the last page — no extra empty-page request.+ assert session.send.call_count == 2+ assert snapshots[0]["url"] == "https://acme.aha.io/api/v1/ideas"+ assert snapshots[0]["params"] == {"per_page": PER_PAGE, "page": 1}+ assert snapshots[1]["params"] == {"per_page": PER_PAGE, "page": 2}++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_auth_is_framework_bearer(self, MockSession) -> None:+ session = MockSession.return_value+ snapshots = _wire(session, [_response("ideas", [{"id": "1"}], total_pages=1)])++ _rows(_source("ideas", _make_manager()))++ auth = snapshots[0]["auth"]+ assert isinstance(auth, BearerTokenAuth)+ assert auth.token == "key"++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_saves_resume_state_only_while_pages_remain(self, MockSession) -> None:+ session = MockSession.return_value+ _wire(+ session,+ [+ _response("ideas", [{"id": "1"}], current_page=1, total_pages=2),+ _response("ideas", [{"id": "2"}], current_page=2, total_pages=2),+ ],+ )++ manager = _make_manager()+ _rows(_source("ideas", manager))++ # State is saved only while more pages remain (page 1 -> next_page 2), never on the last page.+ manager.save_state.assert_called_once()+ assert manager.save_state.call_args.args[0] == AhaIdeasResumeConfig(next_page=2)++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_resumes_from_saved_page(self, MockSession) -> None:+ session = MockSession.return_value+ snapshots = _wire(session, [_response("ideas", [{"id": "2"}], current_page=2, total_pages=2)])++ rows = _rows(_source("ideas", _make_manager(AhaIdeasResumeConfig(next_page=2))))++ assert [r["id"] for r in rows] == ["2"]+ assert session.send.call_count == 1+ assert snapshots[0]["params"]["page"] == 2++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_incremental_cursor_added_to_request(self, MockSession) -> None:+ session = MockSession.return_value+ snapshots = _wire(session, [_response("ideas", [{"id": "1"}], total_pages=1)])++ _rows(+ _source(+ "ideas",+ _make_manager(),+ should_use_incremental_field=True,+ db_incremental_field_last_value=datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC),+ )+ )++ assert snapshots[0]["params"]["updated_since"] == "2026-03-04T02:58:14Z"++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_uses_response_key_for_idea_endorsements(self, MockSession) -> None:+ # Votes live at /ideas/endorsements with an `idea_endorsements` root key.+ session = MockSession.return_value+ snapshots = _wire(session, [_response("idea_endorsements", [{"id": "v1"}], total_pages=1)])++ rows = _rows(_source("idea_endorsements", _make_manager()))++ assert [r["id"] for r in rows] == ["v1"]+ assert snapshots[0]["url"] == "https://acme.aha.io/api/v1/ideas/endorsements"++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_stops_on_empty_page(self, MockSession) -> None:+ session = MockSession.return_value+ _wire(session, [_response("idea_portals", [], total_pages=1)])++ manager = _make_manager()+ rows = _rows(_source("idea_portals", manager))++ assert rows == []+ assert session.send.call_count == 1+ manager.save_state.assert_not_called()++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_missing_response_key_stops_quietly(self, MockSession) -> None:+ # A body without the root key is treated as an empty page.+ session = MockSession.return_value+ _wire(session, [_response("idea_portals", None, drop_key=True)])++ rows = _rows(_source("idea_portals", _make_manager()))++ assert rows == []+ assert session.send.call_count == 1++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_missing_metadata_partial_page_stops(self, MockSession) -> None:+ # No pagination metadata + a short page -> no more pages (full-page fallback heuristic).+ session = MockSession.return_value+ _wire(session, [_response("ideas", [{"id": "1"}, {"id": "2"}])])++ rows = _rows(_source("ideas", _make_manager()))++ assert [r["id"] for r in rows] == ["1", "2"]+ assert session.send.call_count == 1++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_missing_metadata_full_page_continues(self, MockSession) -> None:+ # No pagination metadata + a full page -> there may be more pages.+ session = MockSession.return_value+ full_page = [{"id": str(i)} for i in range(PER_PAGE)]+ _wire(session, [_response("ideas", full_page), _response("ideas", [{"id": "last"}])])++ rows = _rows(_source("ideas", _make_manager()))++ assert len(rows) == PER_PAGE + 1+ assert session.send.call_count == 2+++class TestAhaIdeasSourceFanout:+ @mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources"+ )+ def test_idea_comments_fanout_row_format(self, mock_rest_api_resources) -> None:+ mock_rest_api_resources.return_value = [+ _FakeDltResource("ideas", [{"id": "idea_1"}]),+ _FakeDltResource("idea_comments", [{"id": "comment_1", "idea_id": "idea_1"}]),+ ]++ response = aha_ideas_source(+ subdomain="acme",+ api_key="key",+ endpoint="idea_comments",+ team_id=1,+ job_id="j",+ resumable_source_manager=_make_manager(),+ )++ rows = list(cast(Any, response.items()))+ assert rows == [{"id": "comment_1", "idea_id": "idea_1"}]+ assert response.primary_keys == ["id", "idea_id"]+ assert response.partition_mode == "datetime"+ assert response.partition_keys == ["created_at"]++ @mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.aha_ideas.build_dependent_resource"+ )+ def test_idea_comments_fanout_wires_selectors(self, mock_build_dependent_resource) -> None:+ mock_build_dependent_resource.return_value = iter([])++ aha_ideas_source(+ subdomain="acme",+ api_key="key",+ endpoint="idea_comments",+ team_id=1,+ job_id="j",+ resumable_source_manager=_make_manager(),+ )++ kwargs = mock_build_dependent_resource.call_args.kwargs+ assert kwargs["page_size_param"] == "per_page"+ assert kwargs["parent_endpoint_extra"]["data_selector"] == "ideas"+ assert kwargs["child_endpoint_extra"]["data_selector"] == "idea_comments"+ assert kwargs["should_use_incremental_field"] is False+ assert kwargs["fanout"].parent_name == "ideas"+ assert kwargs["fanout"].resolve_param == "idea_id"+ assert kwargs["fanout"].resolve_field == "id"+++class TestValidateCredentials:+ @mock.patch(AHA_IDEAS_SESSION_PATCH)+ def test_ok(self, mock_session) -> None:+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)+ assert validate_credentials("acme", "key") == (True, 200)++ @mock.patch(AHA_IDEAS_SESSION_PATCH)+ def test_unauthorized(self, mock_session) -> None:+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=401)+ assert validate_credentials("acme", "key") == (False, 401)++ @mock.patch(AHA_IDEAS_SESSION_PATCH)+ def test_swallows_transport_errors(self, mock_session) -> None:+ mock_session.return_value.get.side_effect = Exception("boom")+ assert validate_credentials("acme", "key") == (False, None)++ @mock.patch(AHA_IDEAS_SESSION_PATCH)+ def test_probes_me_endpoint_with_bearer_header(self, mock_session) -> None:+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)+ validate_credentials("acme", "key")++ call = mock_session.return_value.get.call_args+ assert call.args[0] == "https://acme.aha.io/api/v1/me"+ assert call.kwargs["headers"]["Authorization"] == "Bearer key"++ @mock.patch(AHA_IDEAS_SESSION_PATCH)+ def test_bad_subdomain_raises_before_probe(self, mock_session) -> None:+ with pytest.raises(ValueError, match="Invalid Aha! account domain"):+ validate_credentials("acme/../evil", "key")+ mock_session.assert_not_called()diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas_source.pynew file mode 100644index 000000000000..ca30893dfe05--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas_source.py@@ -0,0 +1,174 @@+import pytest+from unittest import mock++from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType++from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.aha_ideas import AhaIdeasResumeConfig+from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.settings import (+ AHA_IDEAS_ENDPOINTS,+ ENDPOINTS,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.source import AhaIdeasSource+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.ahaideas import (+ AhaIdeasSourceConfig,+)+from products.warehouse_sources.backend.types import ExternalDataSourceType++# Endpoints whose Aha! Ideas list action exposes the server-side `updated_since` filter.+_INCREMENTAL_ENDPOINTS = {"ideas", "idea_organizations", "idea_users", "idea_endorsements"}+_FULL_REFRESH_ENDPOINTS = {"idea_portals", "idea_themes", "idea_comments"}+++class TestAhaIdeasSource:+ def setup_method(self):+ self.source = AhaIdeasSource()+ self.team_id = 123+ self.config = AhaIdeasSourceConfig(subdomain="acme", api_key="key")++ def test_source_type(self):+ assert self.source.source_type == ExternalDataSourceType.AHAIDEAS++ def test_get_source_config(self):+ config = self.source.get_source_config++ assert config.name.value == "AhaIdeas"+ assert config.label == "Aha! Ideas"+ assert config.releaseStatus == ReleaseStatus.ALPHA+ assert config.unreleasedSource is None+ assert config.iconPath == "/static/services/aha_ideas.png"+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/aha-ideas"++ field_names = [f.name for f in config.fields if isinstance(f, SourceFieldInputConfig)]+ assert field_names == ["subdomain", "api_key"]++ def test_api_key_field_is_secret_password(self):+ config = self.source.get_source_config+ api_key_field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "api_key")+ assert api_key_field.type == SourceFieldInputConfigType.PASSWORD+ assert api_key_field.secret is True+ assert api_key_field.required is True++ def test_subdomain_listed_as_connection_host_field(self):+ # The API key is sent to <subdomain>.aha.io, so retargeting the subdomain must re-require it.+ assert self.source.connection_host_fields == ["subdomain"]++ @pytest.mark.parametrize(+ "observed_error",+ [+ "401 Client Error: Unauthorized for url: https://acme.aha.io/api/v1/ideas?page=1&per_page=200",+ "403 Client Error: Forbidden for url: https://acme.aha.io/api/v1/idea_portals?page=1&per_page=200",+ ],+ )+ def test_non_retryable_errors_match_auth_failures(self, observed_error):+ non_retryable_errors = self.source.get_non_retryable_errors()+ assert any(key in observed_error for key in non_retryable_errors)++ @pytest.mark.parametrize(+ "other_error",+ [+ "429 Client Error: Too Many Requests for url: https://acme.aha.io/api/v1/ideas",+ "500 Server Error: Internal Server Error for url: https://acme.aha.io/api/v1/ideas",+ "HTTPSConnectionPool(host='acme.aha.io', port=443): Read timed out.",+ ],+ )+ def test_non_retryable_errors_do_not_match_transient(self, other_error):+ non_retryable_errors = self.source.get_non_retryable_errors()+ assert not any(key in other_error for key in non_retryable_errors)++ def test_get_schemas_match_endpoints_with_correct_sync_modes(self):+ schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}++ assert set(schemas) == set(ENDPOINTS)+ for name in _INCREMENTAL_ENDPOINTS:+ assert schemas[name].supports_incremental is True+ assert schemas[name].supports_append is True+ assert [f["field"] for f in schemas[name].incremental_fields] == ["updated_at"]+ for name in _FULL_REFRESH_ENDPOINTS:+ assert schemas[name].supports_incremental is False+ assert schemas[name].supports_append is False+ assert schemas[name].incremental_fields == []++ def test_get_schemas_filtered_by_names(self):+ schemas = self.source.get_schemas(self.config, self.team_id, names=["ideas"])+ assert len(schemas) == 1+ assert schemas[0].name == "ideas"++ def test_get_schemas_filtered_unknown_name_returns_empty(self):+ assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []++ def test_lists_tables_without_credentials_publishes_catalog(self):+ # Static endpoint catalog (no I/O) — the public docs table list should render.+ assert self.source.lists_tables_without_credentials is True+ documented = self.source.get_documented_tables()+ assert {table["name"] for table in documented} == set(ENDPOINTS)++ def test_canonical_descriptions_cover_every_endpoint(self):+ canonical = self.source.get_canonical_descriptions()+ assert set(canonical) == set(AHA_IDEAS_ENDPOINTS)++ @pytest.mark.parametrize(+ "mock_return, expected_valid, expected_message",+ [+ ((True, 200), True, None),+ ((False, 401), False, "Invalid Aha! API key"),+ ((False, 403), False, "Could not connect to Aha! with the provided account domain and API key"),+ ((False, None), False, "Could not connect to Aha! with the provided account domain and API key"),+ ],+ )+ @mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.source.validate_aha_ideas_credentials"+ )+ def test_validate_credentials(self, mock_validate, mock_return, expected_valid, expected_message):+ mock_validate.return_value = mock_return++ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)++ assert is_valid is expected_valid+ assert error_message == expected_message+ mock_validate.assert_called_once_with("acme", "key")++ @mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.source.validate_aha_ideas_credentials"+ )+ def test_validate_credentials_surfaces_bad_subdomain(self, mock_validate):+ mock_validate.side_effect = ValueError("Invalid Aha! account domain: 'a/b'.")++ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)++ assert is_valid is False+ assert "Invalid Aha! account domain" in (error_message or "")++ def test_get_resumable_source_manager_bound_to_resume_config(self):+ inputs = mock.MagicMock()+ manager = self.source.get_resumable_source_manager(inputs)+ assert manager._data_class is AhaIdeasResumeConfig++ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.source.aha_ideas_source")+ def test_source_for_pipeline_plumbs_arguments(self, mock_aha_ideas_source):+ inputs = mock.MagicMock()+ inputs.schema_name = "ideas"+ inputs.should_use_incremental_field = True+ inputs.db_incremental_field_last_value = "2026-01-01T00:00:00Z"+ inputs.incremental_field = "updated_at"+ manager = mock.MagicMock()++ self.source.source_for_pipeline(self.config, manager, inputs)++ mock_aha_ideas_source.assert_called_once()+ kwargs = mock_aha_ideas_source.call_args.kwargs+ assert kwargs["subdomain"] == "acme"+ assert kwargs["api_key"] == "key"+ assert kwargs["endpoint"] == "ideas"+ assert kwargs["resumable_source_manager"] is manager+ assert kwargs["db_incremental_field_last_value"] == "2026-01-01T00:00:00Z"++ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.aha_ideas.source.aha_ideas_source")+ def test_source_for_pipeline_omits_cursor_when_not_incremental(self, mock_aha_ideas_source):+ inputs = mock.MagicMock()+ inputs.schema_name = "idea_portals"+ inputs.should_use_incremental_field = False+ inputs.db_incremental_field_last_value = "2026-01-01T00:00:00Z"++ self.source.source_for_pipeline(self.config, mock.MagicMock(), inputs)++ assert mock_aha_ideas_source.call_args.kwargs["db_incremental_field_last_value"] is Nonediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/ahaideas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/ahaideas.pyindex 940699d2f978..9f2c5db781d2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/ahaideas.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/ahaideas.py@@ -6,4 +6,5 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common imp@config.configclass AhaIdeasSourceConfig(config.Config):- pass+ subdomain: str+ api_key: str