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.

chore(security): hide secret dataclass fields from repr (#83496)

Arno Hillen4ebda23da378
diff --git a/ee/api/agentic_provisioning/github_grants.py b/ee/api/agentic_provisioning/github_grants.py
index 463de5aea7fd..0117ca5e6f1f 100644
--- a/ee/api/agentic_provisioning/github_grants.py
+++ b/ee/api/agentic_provisioning/github_grants.py
@@ -14,7 +14,7 @@ from __future__ import annotations
import json
import secrets
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import Any
from django.core.cache import cache
@@ -60,8 +60,8 @@ class GitHubGrant:
gh_id: int
gh_login: str
email: str | None
- access_token: str
- refresh_token: str | None
+ access_token: str = field(repr=False)
+ refresh_token: str | None = field(repr=False)
access_token_expires_in: int | None
refresh_token_expires_in: int | None
created_at: str
diff --git a/ee/vercel/client.py b/ee/vercel/client.py
index 3b1e33bb10a0..4ff534047a0d 100644
--- a/ee/vercel/client.py
+++ b/ee/vercel/client.py
@@ -1,5 +1,5 @@
import json
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import Any
from urllib.parse import urlencode
@@ -8,23 +8,25 @@ import structlog
from requests import HTTPError, RequestException, Timeout
from tenacity import retry, retry_if_exception, stop_after_attempt, wait_exponential
+from posthog.dataclasses import frozen
+
logger = structlog.get_logger(__name__)
-@dataclass
+@frozen
class SSOTokenResponse:
- access_token: str
+ access_token: str = field(repr=False)
token_type: str
- id_token: str | None = None
+ id_token: str | None = field(default=None, repr=False)
scope: str | None = None
- refresh_token: str | None = None
+ refresh_token: str | None = field(default=None, repr=False)
error: str | None = None
error_description: str | None = None
-@dataclass
+@frozen
class OAuthTokenResponse:
- access_token: str
+ access_token: str = field(repr=False)
token_type: str
installation_id: str
user_id: str
diff --git a/ee/vercel/integration.py b/ee/vercel/integration.py
index 5b5f25d76da8..c31906f4a482 100644
--- a/ee/vercel/integration.py
+++ b/ee/vercel/integration.py
@@ -2,7 +2,7 @@ import copy
import hmac
import hashlib
from collections.abc import Callable
-from dataclasses import asdict, dataclass
+from dataclasses import asdict, dataclass, field
from typing import Any, Literal, Union
from urllib.parse import quote, urlencode
@@ -19,6 +19,7 @@ import structlog
from rest_framework import exceptions
from posthog.cloud_utils import get_cached_instance_license
+from posthog.dataclasses import frozen
from posthog.event_usage import report_user_signed_up
from posthog.exceptions_capture import capture_exception
from posthog.models.integration import Integration
@@ -86,9 +87,9 @@ class ResourceConfig:
protocolSettings: dict[str, Any] | None = None
-@dataclass
+@frozen
class InstallationCredentials:
- access_token: str
+ access_token: str = field(repr=False)
token_type: str
diff --git a/posthog/llm/gateway_client.py b/posthog/llm/gateway_client.py
index db686e0285ce..640e3a432f36 100644
--- a/posthog/llm/gateway_client.py
+++ b/posthog/llm/gateway_client.py
@@ -1,5 +1,6 @@
import json
from collections.abc import Mapping
+from dataclasses import field
from typing import Literal
from urllib.parse import urlparse
from uuid import UUID, uuid5
@@ -209,7 +210,7 @@ def _gateway_misconfig(url: str, api_key: str) -> str | None:
@frozen
class AIGatewayConfig:
url: str
- api_key: str
+ api_key: str = field(repr=False)
def resolve_ai_gateway_config() -> AIGatewayConfig | None:
diff --git a/posthog/local_bootstrap/config.py b/posthog/local_bootstrap/config.py
index f8bef2460cbc..9a7e19bb6839 100644
--- a/posthog/local_bootstrap/config.py
+++ b/posthog/local_bootstrap/config.py
@@ -3,6 +3,8 @@ from __future__ import annotations
from dataclasses import dataclass, field
from typing import Literal
+from posthog.dataclasses import frozen
+
# Mirrors the file formats and compression methods supported by the PostHog S3 batch export
# feature (see products/batch_exports/.../destinations/constants.py). Kept as a local copy so the
# bootstrapper has no import-time dependency on the Temporal batch-export package.
@@ -24,14 +26,14 @@ class BootstrapConfigError(Exception):
"""Raised when the import configuration is invalid (bad format, missing bucket, etc.)."""
-@dataclass
+@frozen
class S3Location:
"""Where a dump lives and how to authenticate against it."""
bucket: str
prefix: str = ""
access_key_id: str | None = None
- secret_access_key: str | None = None
+ secret_access_key: str | None = field(default=None, repr=False)
region: str | None = None
# Custom S3-compatible endpoint (MinIO, SeaweedFS, Cloudflare R2, ...). None uses AWS.
endpoint_url: str | None = None
@@ -61,13 +63,13 @@ class TableImportConfig:
raise BootstrapConfigError(f"A bucket is required for the {self.table} table")
-@dataclass
+@frozen
class BootstrapConfig:
"""Full configuration for a bootstrap run."""
project_name: str
email: str = ""
- password: str = ""
+ password: str = field(default="", repr=False)
tables: list[TableImportConfig] = field(default_factory=list)
batch_size: int = 10_000
diff --git a/posthog/models/integration.py b/posthog/models/integration.py
index 52536c91d712..bfea4f6fcf85 100644
--- a/posthog/models/integration.py
+++ b/posthog/models/integration.py
@@ -6,7 +6,7 @@ import base64
import hashlib
import secrets
from collections.abc import Iterable, Mapping
-from dataclasses import dataclass
+from dataclasses import dataclass, field, replace
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Any, ClassVar, Literal, NamedTuple, NoReturn, Optional, Self, cast
from urllib.parse import parse_qs, urlencode, urlparse
@@ -728,12 +728,12 @@ def aget_integration_by_id(integration_id: str, team_id: int) -> Integration | N
return Integration.objects.get(id=integration_id, team_id=team_id)
-@dataclass
+@frozen
class OauthConfig:
authorize_url: str
token_url: str
client_id: str
- client_secret: str
+ client_secret: str = field(repr=False)
scope: str
id_path: str
name_path: str
@@ -742,7 +742,7 @@ class OauthConfig:
token_info_config_fields: list[str] | None = None
additional_authorize_params: dict[str, str] | None = None
client_id_fallback: str | None = None
- client_secret_fallback: str | None = None
+ client_secret_fallback: str | None = field(default=None, repr=False)
# When true, the authorize/token-exchange flow uses PKCE (RFC 7636, S256)
pkce: bool = False
# When set, disconnecting the integration also revokes the grant at the provider
@@ -907,8 +907,11 @@ class OauthIntegration:
config = cls._build_oauth_config(kind, region)
fallback = settings.OAUTH_CLIENT_FALLBACKS.get(kind)
if fallback and fallback.get("client_secret"):
- config.client_secret_fallback = fallback["client_secret"]
- config.client_id_fallback = fallback.get("client_id") or config.client_id
+ config = replace(
+ config,
+ client_secret_fallback=fallback["client_secret"],
+ client_id_fallback=fallback.get("client_id") or config.client_id,
+ )
return config
@classmethod
@@ -3428,8 +3431,8 @@ class GitHubUserAuthorization:
gh_id: int
gh_login: str
- access_token: str
- refresh_token: str | None
+ access_token: str = field(repr=False)
+ refresh_token: str | None = field(repr=False)
access_token_expires_in: int | None
refresh_token_expires_in: int | None
@@ -3440,7 +3443,7 @@ class GitHubInstallationAccess:
installation_id: str
installation_info: dict[str, Any]
- access_token: str
+ access_token: str = field(repr=False)
token_expires_at: str # ISO datetime returned by GitHub, e.g. "2024-01-01T14:00:00Z"
repository_selection: str
diff --git a/posthog/settings/kafka.py b/posthog/settings/kafka.py
index cc7c70d372e8..bd0675701a2e 100644
--- a/posthog/settings/kafka.py
+++ b/posthog/settings/kafka.py
@@ -175,7 +175,7 @@ class KafkaProfileSettings:
security_protocol: Optional[str]
sasl_mechanism: Optional[str]
sasl_user: Optional[str]
- sasl_password: Optional[str]
+ sasl_password: Optional[str] = field(repr=False)
producer_settings: dict[str, Any] = field(default_factory=dict)
diff --git a/posthog/temporal/common/codec.py b/posthog/temporal/common/codec.py
index 7b89baebd273..81e19a7b14ca 100644
--- a/posthog/temporal/common/codec.py
+++ b/posthog/temporal/common/codec.py
@@ -10,10 +10,18 @@ from temporalio.converter import PayloadCodec
class _RequiredSettings(typing.Protocol):
"""Protocol for required settings."""
- TEMPORAL_SECRET_KEY: str | bytes
- TEMPORAL_FALLBACK_SECRET_KEYS: collections.abc.Iterable[str | bytes]
- TEST: bool
- DEBUG: bool
+ # Read-only members, so frozen settings objects qualify; from_settings only reads them.
+ @property
+ def TEMPORAL_SECRET_KEY(self) -> str | bytes: ...
+
+ @property
+ def TEMPORAL_FALLBACK_SECRET_KEYS(self) -> collections.abc.Iterable[str | bytes]: ...
+
+ @property
+ def TEST(self) -> bool: ...
+
+ @property
+ def DEBUG(self) -> bool: ...
def _load_as_bytes(raw: str | bytes, /, check_length: bool = True) -> bytes:
diff --git a/posthog/temporal/session_replay/surfacing_score_export_sweep/s3.py b/posthog/temporal/session_replay/surfacing_score_export_sweep/s3.py
index 9a8e667ff09d..bc9bf65823da 100644
--- a/posthog/temporal/session_replay/surfacing_score_export_sweep/s3.py
+++ b/posthog/temporal/session_replay/surfacing_score_export_sweep/s3.py
@@ -11,7 +11,7 @@ Unset bucket → the sweep is disabled."""
from __future__ import annotations
import os
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import Any
from posthog.temporal.session_replay.surfacing_score_export_sweep.constants import (
@@ -35,7 +35,7 @@ class ScoreExportDestination:
# None → default AWS endpoint; keys None → ambient credential chain (IRSA/instance profile).
endpoint: str | None
access_key_id: str | None
- secret_access_key: str | None
+ secret_access_key: str | None = field(repr=False)
def score_export_destination() -> ScoreExportDestination | None:
diff --git a/posthog/test/dataclass_secret_field_exemptions.txt b/posthog/test/dataclass_secret_field_exemptions.txt
new file mode 100644
index 000000000000..efb1f8f2652f
--- /dev/null
+++ b/posthog/test/dataclass_secret_field_exemptions.txt
@@ -0,0 +1,2 @@
+products/managed_warehouse/backend/facade/contracts.py DuckLakeCompiledQuery.s3_secrets
+products/warehouse_sources/backend/temporal/data_imports/sources/anthropic/anthropic.py ClaudeCodeActor.api_key_name
diff --git a/posthog/test/test_dataclass_secret_fields.py b/posthog/test/test_dataclass_secret_fields.py
new file mode 100644
index 000000000000..9a8d25e4bdc2
--- /dev/null
+++ b/posthog/test/test_dataclass_secret_fields.py
@@ -0,0 +1,154 @@
+"""Ratchet guard for secret dataclass fields.
+
+Dataclass fields whose names look like credentials (password, access_token,
+api_key, ...) must be declared with field(repr=False) so the secret cannot
+leak through repr() into tracebacks, logs, or pytest assertion diffs.
+Fields that are legitimately not secrets go in the exemptions file.
+
+Print the current violations (to fix them or to exempt a non-secret):
+
+ python posthog/test/test_dataclass_secret_fields.py
+"""
+
+import ast
+from pathlib import Path
+
+REPO_ROOT = Path(__file__).parents[2]
+EXEMPTIONS_PATH = Path(__file__).parent / "dataclass_secret_field_exemptions.txt"
+SCANNED_ROOTS = ("posthog", "ee", "products", "dags", "common")
+SKIPPED_DIRS = {"node_modules", ".venv", "venv", "__pycache__", ".git", ".mypy_cache", "migrations", "test", "tests"}
+
+SECRET_NAME_TOKENS = (
+ "secret",
+ "password",
+ "passwd",
+ "private_key",
+ "access_token",
+ "refresh_token",
+ "id_token",
+ "session_token",
+ "sas_token",
+ "api_key",
+ "api_token",
+ "client_assertion",
+ "passphrase",
+ "signing_key",
+ "encryption_key",
+)
+
+
+def _dotted_name(node: ast.expr) -> str | None:
+ match node:
+ case ast.Name(id=name):
+ return name
+ case ast.Attribute(value=value, attr=attr):
+ base = _dotted_name(value)
+ return f"{base}.{attr}" if base else None
+ case _:
+ return None
+
+
+def _is_dataclass_decorator(decorator: ast.expr, pydantic_names: set[str]) -> bool:
+ """A stdlib @dataclass or posthog @frozen decorator; names bound by pydantic imports are excluded."""
+ target = decorator.func if isinstance(decorator, ast.Call) else decorator
+ dotted = _dotted_name(target)
+ if dotted is None or "pydantic" in dotted:
+ return False
+ if dotted.split(".")[0] in pydantic_names:
+ return False
+ return dotted in ("dataclass", "frozen") or dotted.endswith((".dataclass", ".frozen"))
+
+
+def _is_secret_name(name: str) -> bool:
+ lowered = name.lower()
+ if lowered.endswith("_id") or "expires" in lowered:
+ return False
+ return any(token in lowered for token in SECRET_NAME_TOKENS)
+
+
+def _hides_repr(value: ast.expr | None) -> bool:
+ """True when the field default is a field(...) call carrying repr=False."""
+ if not isinstance(value, ast.Call):
+ return False
+ dotted = _dotted_name(value.func)
+ if dotted is None or (dotted != "field" and not dotted.endswith(".field")):
+ return False
+ return any(
+ kw.arg == "repr" and isinstance(kw.value, ast.Constant) and kw.value.value is False for kw in value.keywords
+ )
+
+
+def _pydantic_bound_names(tree: ast.Module) -> set[str]:
+ """Local names bound by pydantic imports. Resolving decorator provenance per class (instead of
+ skipping the whole module) keeps stdlib dataclasses inspected in mixed modules where
+ `from pydantic.dataclasses import dataclass` would otherwise be indistinguishable by name."""
+ names: set[str] = set()
+ for node in ast.walk(tree):
+ match node:
+ case ast.ImportFrom(module=str(module), names=aliases) if module == "pydantic" or module.startswith(
+ "pydantic."
+ ):
+ names.update(alias.asname or alias.name for alias in aliases)
+ case ast.Import(names=aliases):
+ for alias in aliases:
+ if alias.name == "pydantic" or alias.name.startswith("pydantic."):
+ names.add(alias.asname or alias.name.split(".")[0])
+ return names
+
+
+def _is_test_file(path: Path) -> bool:
+ return path.name == "conftest.py" or path.name.startswith("test_")
+
+
+def collect_violations() -> list[str]:
+ violations: list[str] = []
+ for root in SCANNED_ROOTS:
+ for path in sorted((REPO_ROOT / root).rglob("*.py")):
+ if SKIPPED_DIRS.intersection(path.parts) or _is_test_file(path):
+ continue
+ source = path.read_text(encoding="utf-8", errors="ignore")
+ if "dataclass" not in source:
+ continue
+ try:
+ tree = ast.parse(source)
+ except SyntaxError:
+ continue
+ pydantic_names = _pydantic_bound_names(tree)
+ relpath = path.relative_to(REPO_ROOT).as_posix()
+ for node in ast.walk(tree):
+ if not isinstance(node, ast.ClassDef):
+ continue
+ if not any(_is_dataclass_decorator(decorator, pydantic_names) for decorator in node.decorator_list):
+ continue
+ for stmt in node.body:
+ if not isinstance(stmt, ast.AnnAssign) or not isinstance(stmt.target, ast.Name):
+ continue
+ if isinstance(stmt.annotation, ast.Name) and stmt.annotation.id == "bool":
+ continue
+ if _is_secret_name(stmt.target.id) and not _hides_repr(stmt.value):
+ violations.append(f"{relpath} {node.name}.{stmt.target.id}")
+ return violations
+
+
+def read_exemptions() -> set[str]:
+ return {line.strip() for line in EXEMPTIONS_PATH.read_text().splitlines() if line.strip()}
+
+
+def test_secret_dataclass_fields_hide_repr() -> None:
+ violations = sorted(set(collect_violations()) - read_exemptions())
+ assert not violations, (
+ "Dataclass fields with secret-looking names must be declared with field(repr=False) "
+ "so repr() cannot leak them into tracebacks and logs. Fix them, or if a flagged field "
+ "is genuinely not a secret, add it to posthog/test/dataclass_secret_field_exemptions.txt:\n"
+ + "\n".join(violations)
+ )
+
+
+if __name__ == "__main__":
+ collected = set(collect_violations())
+ exemptions = read_exemptions()
+ for violation in sorted(collected - exemptions):
+ print(violation) # noqa: T201
+ for stale in sorted(exemptions - collected):
+ print(f"stale exemption: {stale}") # noqa: T201
+ print(f"{len(collected - exemptions)} violations, {len(exemptions)} exemptions") # noqa: T201
diff --git a/products/ai_observability/backend/llm/config.py b/products/ai_observability/backend/llm/config.py
index a5a4dd3047f0..345a89820c2c 100644
--- a/products/ai_observability/backend/llm/config.py
+++ b/products/ai_observability/backend/llm/config.py
@@ -1,7 +1,7 @@
-from dataclasses import dataclass
+from dataclasses import dataclass, field
@dataclass(frozen=True)
class ProviderConfig:
- api_key: str
+ api_key: str = field(repr=False)
base_url: str | None = None
diff --git a/products/batch_exports/backend/service.py b/products/batch_exports/backend/service.py
index ae4ada4e875b..096875d34d43 100644
--- a/products/batch_exports/backend/service.py
+++ b/products/batch_exports/backend/service.py
@@ -2,7 +2,7 @@ import json
import types
import typing
import datetime as dt
-from dataclasses import Field, asdict, dataclass, fields
+from dataclasses import Field, asdict, dataclass, field, fields
from uuid import UUID
from django.conf import settings
@@ -256,7 +256,7 @@ class BaseBatchExportInputs:
return self.is_earliest_backfill
-@dataclass(kw_only=True)
+@dataclass(frozen=False, kw_only=True)
class S3BatchExportInputs(BaseBatchExportInputs):
"""Inputs for S3 export workflow.
@@ -290,7 +290,7 @@ class S3BatchExportInputs(BaseBatchExportInputs):
region: str
prefix: str
aws_access_key_id: str | None = None
- aws_secret_access_key: str | None = None
+ aws_secret_access_key: str | None = field(default=None, repr=False)
compression: str | None = None
file_format: str = "JSONLines"
max_file_size_mb: int | None = None
@@ -300,7 +300,7 @@ class S3BatchExportInputs(BaseBatchExportInputs):
use_virtual_style_addressing: bool = False
-@dataclass(kw_only=True)
+@dataclass(frozen=False, kw_only=True)
class S3FamilyBaseInputs(BaseBatchExportInputs):
"""Shared fields for every S3-family destination.
@@ -313,7 +313,7 @@ class S3FamilyBaseInputs(BaseBatchExportInputs):
region: str
prefix: str
aws_access_key_id: str | None = None
- aws_secret_access_key: str | None = None
+ aws_secret_access_key: str | None = field(default=None, repr=False)
compression: str | None = None
file_format: str = "JSONLines"
max_file_size_mb: int | None = None
@@ -362,7 +362,7 @@ class FileDownloadBatchExportInputs(BaseBatchExportInputs):
expires_in_seconds: int = 3600
-@dataclass(kw_only=True)
+@dataclass(frozen=False, kw_only=True)
class SnowflakeBatchExportInputs(BaseBatchExportInputs):
"""Inputs for Snowflake export workflow.
@@ -378,13 +378,13 @@ class SnowflakeBatchExportInputs(BaseBatchExportInputs):
user: str | None = None
table_name: str = "events"
authentication_type: str = "password"
- password: str | None = None
- private_key: str | None = None
- private_key_passphrase: str | None = None
+ password: str | None = field(default=None, repr=False)
+ private_key: str | None = field(default=None, repr=False)
+ private_key_passphrase: str | None = field(default=None, repr=False)
role: str | None = None
-@dataclass(kw_only=True)
+@dataclass(frozen=False, kw_only=True)
class PostgresBatchExportInputs(BaseBatchExportInputs):
"""Inputs for Postgres export workflow."""
@@ -395,18 +395,18 @@ class PostgresBatchExportInputs(BaseBatchExportInputs):
user: str | None = None
host: str | None = None
port: int | None = 5432
- password: str | None = None
+ password: str | None = field(default=None, repr=False)
has_self_signed_cert: bool = False
IAMRole = str
-@dataclass
+@dataclass(frozen=False)
class AWSCredentials:
aws_access_key_id: str
- aws_secret_access_key: str
- aws_session_token: str | None = None
+ aws_secret_access_key: str = field(repr=False)
+ aws_session_token: str | None = field(default=None, repr=False)
@dataclass
@@ -422,12 +422,12 @@ class RedshiftCopyInputs:
bucket_credentials: AWSCredentials
-@dataclass(kw_only=True)
+@dataclass(frozen=False, kw_only=True)
class RedshiftBatchExportInputs(BaseBatchExportInputs):
"""Inputs for Redshift export workflow."""
user: str
- password: str
+ password: str = field(repr=False)
host: str
database: str
schema: str = "public"
@@ -473,14 +473,14 @@ class RedshiftBatchExportInputs(BaseBatchExportInputs):
)
-@dataclass(kw_only=True)
+@dataclass(frozen=False, kw_only=True)
class BigQueryBatchExportInputs(BaseBatchExportInputs):
"""Inputs for BigQuery export workflow."""
dataset_id: str
table_id: str = "events"
project_id: str | None = None
- private_key: str | None = None
+ private_key: str | None = field(default=None, repr=False)
private_key_id: str | None = None
token_uri: str | None = None
client_email: str | None = None
diff --git a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py
index 4a3bd60a563e..fa515ae5b539 100644
--- a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py
@@ -1318,14 +1318,14 @@ def _get_merge_settings(
return MergeSettings(primary_key, version_key)
[email protected](kw_only=True)
[email protected](frozen=False, kw_only=True)
class BigQueryInsertInputs(BatchExportInsertInputs):
"""Inputs for BigQuery."""
dataset_id: str
table_id: str
project_id: str | None = None
- private_key: str | None = None
+ private_key: str | None = dataclasses.field(default=None, repr=False)
private_key_id: str | None = None
token_uri: str | None = None
client_email: str | None = None
diff --git a/products/batch_exports/backend/temporal/destinations/postgres_batch_export.py b/products/batch_exports/backend/temporal/destinations/postgres_batch_export.py
index 57e3bdb1e7e1..e05907a7bca6 100644
--- a/products/batch_exports/backend/temporal/destinations/postgres_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/postgres_batch_export.py
@@ -177,7 +177,7 @@ class _PostgreSQLClientInputsProtocol(typing.Protocol):
def tls(self) -> TLS: ...
[email protected](kw_only=True)
[email protected](frozen=False, kw_only=True)
class PostgresInsertInputs(BatchExportInsertInputs):
"""Inputs for Postgres."""
@@ -187,7 +187,7 @@ class PostgresInsertInputs(BatchExportInsertInputs):
host: str | None = None
port: int | None = None
user: str | None = None
- password: str | None = None
+ password: str | None = dataclasses.field(default=None, repr=False)
has_self_signed_cert: bool | None = None
integration_id: int | None = None
diff --git a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
index a8891458e0dc..c5d83db53141 100644
--- a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py
@@ -18,6 +18,7 @@ from structlog.contextvars import bind_contextvars
from temporalio import activity, exceptions, workflow
from temporalio.common import RetryPolicy
+from posthog.dataclasses import frozen
from posthog.models import Team
from posthog.models.integration import TLS, Authority, Credentials
from posthog.temporal.common.base import PostHogWorkflow
@@ -645,10 +646,10 @@ class CopyParameters:
authorization: IAMRole | AWSCredentials
+@frozen
class ConnectionParameters:
user: str
- password: str
+ password: str = dataclasses.field(repr=False)
host: str
port: int
database: str
diff --git a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py b/products/batch_exports/backend/temporal/destinations/s3_batch_export.py
index d023b11d652b..0fb023a1718e 100644
--- a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/s3_batch_export.py
@@ -165,7 +165,7 @@ async def _get_s3_integration(
)
[email protected](kw_only=True)
[email protected](frozen=False, kw_only=True)
class S3InsertInputs(BatchExportInsertInputs):
"""Inputs for S3 exports."""
@@ -180,8 +180,8 @@ class S3InsertInputs(BatchExportInsertInputs):
# at run time; otherwise the inline credentials below are used (legacy path).
integration_id: int | None = None
aws_access_key_id: str | None = None
- aws_secret_access_key: str | None = None
- aws_session_token: str | None = None
+ aws_secret_access_key: str | None = dataclasses.field(default=None, repr=False)
+ aws_session_token: str | None = dataclasses.field(default=None, repr=False)
compression: str | None = None
encryption: str | None = None
kms_key_id: str | None = None
diff --git a/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py b/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
index f59c0974c7ea..47c72b094f7e 100644
--- a/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
@@ -468,7 +468,7 @@ class SnowflakeTable(Table):
return self
[email protected](kw_only=True)
[email protected](frozen=False, kw_only=True)
class SnowflakeInsertInputs(BatchExportInsertInputs):
"""Inputs for Snowflake."""
@@ -486,9 +486,9 @@ class SnowflakeInsertInputs(BatchExportInsertInputs):
user: str | None = None
account: str | None = None
authentication_type: str = "password"
- password: str | None = None
- private_key: str | None = None
- private_key_passphrase: str | None = None
+ password: str | None = dataclasses.field(default=None, repr=False)
+ private_key: str | None = dataclasses.field(default=None, repr=False)
+ private_key_passphrase: str | None = dataclasses.field(default=None, repr=False)
role: str | None = None
diff --git a/products/conversations/backend/temporal/zendesk_import/client.py b/products/conversations/backend/temporal/zendesk_import/client.py
index 485646a0b4b4..7b8cef4b92e6 100644
--- a/products/conversations/backend/temporal/zendesk_import/client.py
+++ b/products/conversations/backend/temporal/zendesk_import/client.py
@@ -5,7 +5,7 @@ from __future__ import annotations
import re
import time
import base64
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import Any
from urllib.parse import urlsplit
@@ -77,7 +77,7 @@ class ZendeskAttachmentTooLargeError(Exception):
class ZendeskCredentials:
subdomain: str
email_address: str
- api_token: str
+ api_token: str = field(repr=False)
class ZendeskImportClient:
diff --git a/products/managed_warehouse/backend/facade/contracts.py b/products/managed_warehouse/backend/facade/contracts.py
index 60a6164bbfe2..898319812e9e 100644
--- a/products/managed_warehouse/backend/facade/contracts.py
+++ b/products/managed_warehouse/backend/facade/contracts.py
@@ -138,7 +138,7 @@ class DuckgresQueryServerConfig:
flight_port: int
database: str
username: str
- password: str
+ password: str = field(repr=False)
@dataclass(frozen=True, kw_only=True)
@@ -149,7 +149,7 @@ class DuckLakeCatalogConnectionConfig:
port: int
database: str
username: str | None
- password: str | None
+ password: str | None = field(repr=False)
@dataclass(frozen=True, kw_only=True)
diff --git a/products/managed_warehouse/backend/storage.py b/products/managed_warehouse/backend/storage.py
index 55167ba50f8a..5cfba69be42e 100644
--- a/products/managed_warehouse/backend/storage.py
+++ b/products/managed_warehouse/backend/storage.py
@@ -150,7 +150,7 @@ class DuckLakeStorageConfig:
"""
access_key: str
- secret_key: str
+ secret_key: str = dataclasses.field(repr=False)
region: str
endpoint: str
use_ssl: bool
diff --git a/products/mcp_store/backend/oauth.py b/products/mcp_store/backend/oauth.py
index d710b8d4fd46..e7b1b08e2dc0 100644
--- a/products/mcp_store/backend/oauth.py
+++ b/products/mcp_store/backend/oauth.py
@@ -411,7 +411,7 @@ def _credential_auth_method(credentials: dict, auth_method_key: str, client_secr
class InstallationOAuthContext:
metadata: dict
client_id: str
- client_secret: str | None
+ client_secret: str | None = dataclasses.field(repr=False)
token_endpoint_auth_method: str
diff --git a/products/tasks/backend/logic/services/connection_token.py b/products/tasks/backend/logic/services/connection_token.py
index a49da81d47c5..b64849e180b8 100644
--- a/products/tasks/backend/logic/services/connection_token.py
+++ b/products/tasks/backend/logic/services/connection_token.py
@@ -1,7 +1,7 @@
from __future__ import annotations
import hashlib
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from datetime import UTC, datetime, timedelta
from functools import lru_cache
from typing import TYPE_CHECKING, Any
@@ -44,7 +44,7 @@ class SandboxEventIngestTokenPayload:
@dataclass(frozen=True)
class _SandboxJwtKey:
kid: str
- private_key_pem: str
+ private_key_pem: str = field(repr=False)
public_key_pem: str
diff --git a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py b/products/tasks/backend/temporal/process_task/activities/start_agent_server.py
index fe1460c6194f..1dda8a969b78 100644
--- a/products/tasks/backend/temporal/process_task/activities/start_agent_server.py
+++ b/products/tasks/backend/temporal/process_task/activities/start_agent_server.py
@@ -1,6 +1,6 @@
import shlex
import threading
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from datetime import UTC, datetime
from django.conf import settings
@@ -8,6 +8,7 @@ from django.db import connection
from temporalio import activity
+from posthog.dataclasses import frozen
from posthog.models import Integration
from posthog.models.integration import GitHubIntegration
from posthog.models.user_integration import UserGitHubIntegration, UserIntegration
@@ -180,7 +181,7 @@ class StartAgentServerOutput:
boot_total_ms: int | None = None
-@dataclass
+@frozen
class _LaunchParams:
mcp_configs: list[McpServerConfig]
relayed_mcp_servers: list[str]
@@ -189,8 +190,8 @@ class _LaunchParams:
actor_user_id: int | None
agentsh_domains: list[str] | None
protected_base_branch: str | None
- event_ingest_token: str | None
- task_run_session_token: str | None
+ event_ingest_token: str | None = field(repr=False)
+ task_run_session_token: str | None = field(repr=False)
event_ingest_url: str | None
event_ingest_keep_stream_open: bool
diff --git a/products/warehouse_sources/backend/models/ssh_tunnel.py b/products/warehouse_sources/backend/models/ssh_tunnel.py
index df84510de0ee..95c4f4bbcdbf 100644
--- a/products/warehouse_sources/backend/models/ssh_tunnel.py
+++ b/products/warehouse_sources/backend/models/ssh_tunnel.py
@@ -8,6 +8,8 @@ from cryptography.hazmat.primitives.asymmetric import dsa, ec, ed25519, rsa
from paramiko import DSSKey, ECDSAKey, Ed25519Key, PKey, RSAKey
from sshtunnel import SSHTunnelForwarder
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.temporal.data_imports.sources.common import config
# Substrings that mark a private-key parse failure as a wrong/missing passphrase rather than a
@@ -87,7 +89,7 @@ class SSHTunnelConfig(config.Config):
require_tls: SSHTunnelRequireTlsConfig = config.value(default_factory=SSHTunnelRequireTlsConfig)
+@frozen
class SSHTunnel:
enabled: bool
@@ -95,9 +97,9 @@ class SSHTunnel:
port: int | str
auth_type: Literal["password", "keypair"]
username: str | None
- password: str | None
- private_key: str | None
- passphrase: str | None
+ password: str | None = dataclasses.field(repr=False)
+ private_key: str | None = dataclasses.field(repr=False)
+ passphrase: str | None = dataclasses.field(repr=False)
@classmethod
def from_config(cls: type[typing.Self], config: SSHTunnelConfig) -> typing.Self:
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source.py b/products/warehouse_sources/backend/presentation/views/external_data_source.py
index 07a08a004942..d43b747a43e4 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_source.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_source.py
@@ -1793,7 +1793,7 @@ class IntegrationAccountsResponseSerializer(serializers.Serializer):
@dataclasses.dataclass(frozen=True, kw_only=True, slots=True)
class ResolvedStoredCredential:
- payload: dict
+ payload: dict = dataclasses.field(repr=False)
credential: PendingSourceCredential | None
error_response: Response | None
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py
index dba02d31980e..3367726f8cc6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/adobe_commerce/adobe_commerce.py
@@ -12,6 +12,8 @@ import requests
from structlog.types import FilteringBoundLogger
from urllib3.util.retry import Retry
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.temporal.data_imports.sources.adobe_commerce.settings import (
ADOBE_COMMERCE_ENDPOINTS,
VALIDATION_PROBE_ENDPOINTS,
@@ -110,12 +112,12 @@ class AdobeCommerceResumeConfig:
current_page: int
+@frozen
class AdobeCommerceCredentials:
method: Literal["access_token", "admin"]
- access_token: str | None = None
+ access_token: str | None = dataclasses.field(default=None, repr=False)
username: str | None = None
- password: str | None = None
+ password: str | None = dataclasses.field(default=None, repr=False)
def secret_values(self) -> tuple[str, ...]:
return tuple(v for v in (self.access_token, self.password) if v)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/appdynamics/appdynamics.py b/products/warehouse_sources/backend/temporal/data_imports/sources/appdynamics/appdynamics.py
index 91a767db21a2..8570b3850974 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/appdynamics/appdynamics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/appdynamics/appdynamics.py
@@ -13,6 +13,8 @@ from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_ex
from urllib3.connectionpool import HTTPConnectionPool, HTTPSConnectionPool
from urllib3.util.retry import Retry
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.temporal.data_imports.sources.appdynamics.settings import (
APPDYNAMICS_ENDPOINTS,
APPLICATIONS_PATH,
@@ -64,15 +66,15 @@ class AppdynamicsResumeConfig:
window_start: int | None = None
+@frozen
class AppdynamicsAuth:
"""Resolved credentials for a single sync. Exactly one auth style is populated."""
account_name: str
api_client_name: Optional[str] = None
- api_client_secret: Optional[str] = None
+ api_client_secret: Optional[str] = dataclasses.field(default=None, repr=False)
username: Optional[str] = None
- password: Optional[str] = None
+ password: Optional[str] = dataclasses.field(default=None, repr=False)
@property
def uses_oauth(self) -> bool:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/bitbucket.py b/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/bitbucket.py
index cc1b9f0a10aa..e0465c9fe681 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/bitbucket.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/bitbucket/bitbucket.py
@@ -44,8 +44,8 @@ class BitbucketAuth:
or a workspace/repository access token (Bearer)."""
email: str | None = None
- api_token: str | None = None
- access_token: str | None = None
+ api_token: str | None = dataclasses.field(default=None, repr=False)
+ access_token: str | None = dataclasses.field(default=None, repr=False)
def _make_session(auth: BitbucketAuth) -> requests.Session:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/docusign/docusign.py b/products/warehouse_sources/backend/temporal/data_imports/sources/docusign/docusign.py
index c83e31ebb409..6cad016d9124 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/docusign/docusign.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/docusign/docusign.py
@@ -56,9 +56,9 @@ class DocusignCredentials:
selection: str
integration_key: str
user_id: Optional[str] = None
- private_key: Optional[str] = None
- secret_key: Optional[str] = None
- refresh_token: Optional[str] = None
+ private_key: Optional[str] = dataclasses.field(default=None, repr=False)
+ secret_key: Optional[str] = dataclasses.field(default=None, repr=False)
+ refresh_token: Optional[str] = dataclasses.field(default=None, repr=False)
account_id: Optional[str] = None
@property
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/elasticsearch/elasticsearch.py b/products/warehouse_sources/backend/temporal/data_imports/sources/elasticsearch/elasticsearch.py
index 5994e0db7448..c09dd559a9ce 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/elasticsearch/elasticsearch.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/elasticsearch/elasticsearch.py
@@ -7,6 +7,8 @@ import requests
from structlog.types import FilteringBoundLogger
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
+from posthog.dataclasses import frozen
+
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.typings import SourceResponse
@@ -34,11 +36,11 @@ class ElasticsearchRetryableError(Exception):
pass
+@frozen
class ElasticsearchAuth:
username: Optional[str] = None
- password: Optional[str] = None
- api_key: Optional[str] = None
+ password: Optional[str] = dataclasses.field(default=None, repr=False)
+ api_key: Optional[str] = dataclasses.field(default=None, repr=False)
def normalize_host(host: str) -> str:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/firebase.py b/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/firebase.py
index d318af1f3ae1..1b09c35baf4a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/firebase.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/firebase/firebase.py
@@ -74,7 +74,7 @@ class FirebaseResumeConfig:
class FirebaseCredentials:
project_id: str
client_email: str
- private_key: str
+ private_key: str = dataclasses.field(repr=False)
private_key_id: Optional[str] = None
# Kept as it was read from the key file, but never used as a request target — see `token_endpoint`.
token_uri: Optional[str] = None
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/grafana.py b/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/grafana.py
index f96e52dad286..d1dceeed30e0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/grafana.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/grafana.py
@@ -13,6 +13,8 @@ from structlog.types import FilteringBoundLogger
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
from urllib3.util.retry import Retry
+from posthog.dataclasses import frozen
+
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.mixins import _is_host_safe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
@@ -97,15 +99,15 @@ class GrafanaResponseTooLargeError(Exception):
pass
+@frozen
class GrafanaAuth:
# "token" sends a service account token as an Authorization: Bearer header (works on both
# Grafana Cloud and self-hosted); "basic" sends HTTP Basic credentials (self-hosted OSS only —
# Grafana Cloud rejects basic auth on the HTTP API).
method: str
- token: Optional[str] = None
+ token: Optional[str] = dataclasses.field(default=None, repr=False)
username: Optional[str] = None
- password: Optional[str] = None
+ password: Optional[str] = dataclasses.field(default=None, repr=False)
@dataclasses.dataclass
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/jamf_pro/jamf_pro.py b/products/warehouse_sources/backend/temporal/data_imports/sources/jamf_pro/jamf_pro.py
index 59a82bd5cda2..09a82a9fa413 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/jamf_pro/jamf_pro.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/jamf_pro/jamf_pro.py
@@ -11,6 +11,8 @@ import requests
from structlog.types import FilteringBoundLogger
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
+from posthog.dataclasses import frozen
+
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.mixins import _is_host_safe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
@@ -140,13 +142,13 @@ class JamfProResumeConfig:
page: int
+@frozen
class JamfProCredentials:
method: Literal["client_credentials", "basic"]
client_id: str | None = None
- client_secret: str | None = None
+ client_secret: str | None = dataclasses.field(default=None, repr=False)
username: str | None = None
- password: str | None = None
+ password: str | None = dataclasses.field(default=None, repr=False)
def normalize_host(host: str) -> str:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/metabase.py b/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/metabase.py
index f964db8208ce..4c74caa5b5f2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/metabase.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/metabase/metabase.py
@@ -8,6 +8,8 @@ import requests
import structlog
from structlog.types import FilteringBoundLogger
+from posthog.dataclasses import frozen
+
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.mixins import _is_host_safe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
@@ -55,14 +57,14 @@ class MetabaseAuthError(Exception):
pass
+@frozen
class MetabaseAuth:
# "api_key" sends a static X-API-Key header; "session" mints a short-lived token via
# POST /api/session and sends it as X-Metabase-Session (for instances older than v0.47).
method: str
- api_key: Optional[str] = None
+ api_key: Optional[str] = dataclasses.field(default=None, repr=False)
username: Optional[str] = None
- password: Optional[str] = None
+ password: Optional[str] = dataclasses.field(default=None, repr=False)
def normalize_host(host: str) -> str:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/stream_reader.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/stream_reader.py
index 806317cc9db9..33aff7b54e77 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/stream_reader.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/cdc/stream_reader.py
@@ -10,7 +10,7 @@ from __future__ import annotations
import time
from collections.abc import Callable, Iterator
from contextlib import AbstractContextManager
-from dataclasses import dataclass
+from dataclasses import dataclass, field
from typing import TYPE_CHECKING
import psycopg
@@ -63,7 +63,7 @@ class PgCDCConnectionParams:
port: int
database: str
user: str
- password: str
+ password: str = field(repr=False)
require_ssl: bool = False
slot_name: str = ""
publication_name: str = ""
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/qualtrics/qualtrics.py b/products/warehouse_sources/backend/temporal/data_imports/sources/qualtrics/qualtrics.py
index adbe4396d5dc..32f35a241b0f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/qualtrics/qualtrics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/qualtrics/qualtrics.py
@@ -14,6 +14,8 @@ import requests
from structlog.types import FilteringBoundLogger
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
+from posthog.dataclasses import frozen
+
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.mixins import _is_host_safe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
@@ -120,12 +122,12 @@ class QualtricsResumeConfig:
parent_index: int = 0
+@frozen
class QualtricsCredentials:
method: Literal["api_token", "oauth_client_credentials"]
- api_token: str | None = None
+ api_token: str | None = dataclasses.field(default=None, repr=False)
client_id: str | None = None
- client_secret: str | None = None
+ client_secret: str | None = dataclasses.field(default=None, repr=False)
def secret_values(self) -> tuple[str, ...]:
return tuple(value for value in (self.api_token, self.client_secret) if value)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/servicenow/servicenow.py b/products/warehouse_sources/backend/temporal/data_imports/sources/servicenow/servicenow.py
index fde3919deb98..bf3609d50776 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/servicenow/servicenow.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/servicenow/servicenow.py
@@ -5,6 +5,8 @@ from urllib.parse import urlparse
import requests
+from posthog.dataclasses import frozen
+
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.mixins import _is_host_safe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
@@ -57,13 +59,13 @@ class ServiceNowResumeConfig:
offset: int = 0
+@frozen
class ServiceNowAuth:
"""Resolved credentials for a single sync. Exactly one auth style is populated."""
- api_key: Optional[str] = None
+ api_key: Optional[str] = dataclasses.field(default=None, repr=False)
username: Optional[str] = None
- password: Optional[str] = None
+ password: Optional[str] = dataclasses.field(default=None, repr=False)
def headers(self) -> dict[str, str]:
headers = {"Accept": "application/json"}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shutterstock/shutterstock.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shutterstock/shutterstock.py
index b85c43de7f3f..9d3a97e5b4ca 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shutterstock/shutterstock.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shutterstock/shutterstock.py
@@ -45,8 +45,8 @@ class ShutterstockAuth:
OAuth token; the catalog feeds work with either."""
consumer_key: str | None = None
- consumer_secret: str | None = None
- access_token: str | None = None
+ consumer_secret: str | None = dataclasses.field(default=None, repr=False)
+ access_token: str | None = dataclasses.field(default=None, repr=False)
def _auth_config(auth: ShutterstockAuth) -> AuthConfig:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py
index 6118b4411a07..48ddbe5fa183 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py
@@ -12,6 +12,7 @@ from structlog.types import FilteringBoundLogger
from temporalio.client import Client
from temporalio.service import RPCError, RPCStatusCode
+from posthog.dataclasses import frozen
from posthog.temporal.common.client import connect
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
@@ -252,12 +253,12 @@ def _sanitize(obj):
return {k: safe_convert(v) for k, v in obj.items()}
+@frozen
class FakeSettings:
"""Required to trick temporal.io client to think its reading from django settings"""
- TEMPORAL_SECRET_KEY: str | bytes
- TEMPORAL_FALLBACK_SECRET_KEYS: Iterable[str | bytes] = dataclasses.field(default_factory=list)
+ TEMPORAL_SECRET_KEY: str | bytes = dataclasses.field(repr=False)
+ TEMPORAL_FALLBACK_SECRET_KEYS: Iterable[str | bytes] = dataclasses.field(default_factory=list, repr=False)
TEST: bool = False
DEBUG: bool = False