Repository navigation
fix(integrations): remove github only filter in mcp/api - #56996
Conversation
The list/retrieve endpoints filtered to `kind="github"` for personal API key and OAuth access token auth (added in #38921 as defense in depth — the author hadn't audited every kind's `config` for stray secrets). Audited all 33 kinds across `OauthIntegration` and the bespoke creators (Twilio, Email, Firebase, GoogleCloud, Databricks, AzureBlob, Postgres, GitLab, GitHub, Vercel, the CustomerIO variants); checked prod-us and prod-eu for the kinds I was unsure about. Every row's `config` only carries display IDs, scopes, public URLs, the connecting user's email, and expiry timestamps — secrets all live in `sensitive_config`, which IntegrationSerializer never returns. The filter is no longer doing useful work, so drop the override entirely.
Drop the vercel fixture and three-kind loops added in the previous commit — the behavior change is binary (api keys can see non-github kinds now), so github + twilio is enough to demonstrate it. Restore original test names and the session-auth assertion shape.
|
Reviews (1): Last reviewed commit: "test(integrations): slim down access-con..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12737111d0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Resolved conflicts in posthog/api/integration.py and posthog/api/test/test_integration.py: kept this branch's removal of the api-key kind filter (exposing all integration kinds), preserved SessionAuthentication import for the channels action from master, and dropped master's github+slack-only list test that contradicts this change. Kept master's sensitive_config-not-leaked assertion.
Removing the github-only queryset filter for api-key callers means github_repos, refresh_github_repos, and github_branches can now resolve non-github integration IDs and would 500 because GitHubIntegration's constructor raises a bare Exception when kind != "github". Add a kind check before constructing GitHubIntegration so callers get a 400 with a clear message instead. Updates the existing channels matrix test to reflect that twilio now resolves through the queryset and trips the slack-kind guard (400) rather than 404ing on resolution.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fe3a4cde8d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…cription The integrations-list MCP tool description claimed only GitHub and Slack were returned for personal API key / OAuth callers. That gating was removed earlier on this branch, so reword the description to reflect the actual behavior and call out that sensitive credentials are never serialized.
MCP UI Apps size report
|
…-types Resolves merge conflicts after ~924 master commits and addresses Greptile review feedback on the original PR. Conflict resolutions: - posthog/api/integration.py: kept SlackChannelsQuerySerializer from this branch, dropped the now-redundant safely_get_queryset filter (master PRs #56996 and a509241d8b8 already expose all kinds to PAK/OAuth), used master's SLACK_INTEGRATION_KINDS constant in the kind guard. - posthog/api/test/test_integration.py: adopted master's list/twilio/slack retrieval tests; dropped the filter-specific test that no longer applies. - products/cdp/mcp/cdp_functions.yaml: adopted master's richer Slack recipe (text + blocks from the alert-wizard sub-template) and tighter dedupe. - products/integrations/mcp/tools.yaml: kept the rate-limit note on channels; took master's list-tool description. - All generated files regenerated via hogli build:openapi. Greptile P2 review feedback addressed: - frontend/src/lib/integrations/slackIntegrationLogic.ts: guard allSlackChannels?.lastRefreshedAt so a single-channel-lookup response doesn't silently disable the refresh-cooldown check. - posthog/api/integration.py: SlackChannelsQuerySerializer now validates at runtime (is_valid(raise_exception=True)); the view reads from validated_data — turns the OpenAPI promise into the truth instead of documentation-only.
Problem
we need this for setting up sources with oauth integrations via the mcp
The Integration list/retrieve endpoints filtered to
kind="github"whenever the request authed viaPersonalAPIKeyAuthenticationorOAuthAccessTokenAuthentication. Introduced in #38921 as a defensive measure — the author hadn't audited every integration kind'sconfigfield for stray secrets and chose to expose only the one kind they were sure about. Side-effect: every other integration is invisible to API-key callers (e.g. the PostHog MCP server, which authenticates via OAuth access token), so the MCP can't list HubSpot, Slack, or any other integration on behalf of the user.Changes
Integration.configvsIntegration.sensitive_config.google-pubsub,google-cloud-storage,vercel): every row'sconfigonly contains harmless metadata (expiry timestamps, display IDs, scopes, public URLs). No row has ever held service-account keyfiles or unbounded user-supplied JSON.IntegrationSerializeralready excludessensitive_config, so the kind-allowlist filter wasn't actually buying anything beyond what the model contract already does.safely_get_querysetoverride and the now-unused auth-class imports. Personal-API-key and OAuth-access-token callers fall through to the default queryset (still team-filtered byTeamAndOrgViewSetMixin, still has therepository_cachedeferral).How did you test this code?
I'm an agent (Claude). Tests run:
hogli test posthog/api/test/test_integration.py— 72 passed (one removed: the test that asserted non-github kinds were 404 for API keys, since that's the exact behavior being removed).Manual verification: re-ran
posthog-local'sintegrations-listMCP tool against my dev instance — previously returned 0 results under OAuth access-token auth, now returns the HubSpot and Slack integrations as expected.Publish to changelog?
no
Docs update
n/a — internal API behavior change, no docs surface.
🤖 Agent context
integrations-listtool returned 0 results, which led to discovering the GitHub-only filter.integration_from_*and bespoke creator inposthog/models/integration.py, plus the customerio-* creators inproducts/messaging/backend/api/message_categories.pyand the vercel creator inee/vercel/integration.py. ConfirmedOauthIntegration.integration_from_oauth_responsepopsaccess_token/refresh_token/id_tokentosensitive_configfor all OAuth kinds. Verified prod-us + prod-eu Postgres via Metabase for the three kinds I had specific concerns about.