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.

735 B
Raw Blame
"""GitHub API helpers with caching."""

from __future__ import annotations

from owners_yaml.github import GitHubLookupError, GitHubOrg

_ORG = GitHubOrg("PostHog")


def get_team_slugs() -> tuple[set[str] | None, str]:
    """Fetch GitHub team slugs visible in the PostHog org. Cached after the first call.

    The org lookup is broader than repo access. assign-reviewers.js covers a team that exists
    in the org but lacks repo access with its 422 fallback, which retries each team individually
    and logs the bad slugs.

    Returns ``(slugs, error_message)``. ``slugs`` is ``None`` when the fetch failed.
    """
    try:
        return _ORG.team_slugs(), ""
    except GitHubLookupError as exc:
        return None, str(exc)