Skip to content

feat: request read-data-schema + notebook OAuth scopes and document the scope set#513

Open
gewenyu99 wants to merge 7 commits into
mainfrom
posthog-code/document-oauth-scopes
Open

feat: request read-data-schema + notebook OAuth scopes and document the scope set#513
gewenyu99 wants to merge 7 commits into
mainfrom
posthog-code/document-oauth-scopes

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

The wizard agent's schema-discovery tool (read-data-schema) is gated on event_definition:read + property_definition:read. The wizard never requested those scopes on its base scope set, so schema discovery failed and the agent fell back to guessing event names from capture() calls in code.

The OAuth scopes the wizard requests also weren't documented anywhere operators could find them, and the README had no guard against drifting from the constants.

Changes

  • src/lib/constants.ts — add event_definition:read + property_definition:read to WIZARD_PROVISIONING_SCOPES (not just the OAuth set). Because WIZARD_OAUTH_SCOPES spreads the provisioning set, both auth paths now request them with no duplication:

    • signup / provisioning path (provisioning.tsWIZARD_PROVISIONING_SCOPES)
    • OAuth login path (setup-utils.tsgetOAuthScopesForProgram)

    This is the key correction over the earlier version of this branch, which added the scopes only to WIZARD_OAUTH_SCOPES and left newly-provisioned users without schema access.

  • src/utils/__tests__/provisioning.test.ts — assert the two new provisioning scopes.

  • README — an honest "OAuth Scopes" section: the base set every program requests, a note that the set is program-dependent (programs like the MCP tutorial layer extra read scopes via PROGRAM_SCOPE_ADDITIONS), and both grant prerequisites spelled out.

  • MAINTAINING-SKILLS.md — note covering all three scope surfaces (WIZARD_PROVISIONING_SCOPES, WIZARD_OAUTH_SCOPES, PROGRAM_SCOPE_ADDITIONS) and the two grant prerequisites.

⚠️ Prerequisites before this ships (out of repo)

This change is inert until both land — and the first is a hard requirement or signup breaks:

  1. Add event_definition:read + property_definition:read to ALLOWED_PROVISIONING_SCOPES in the monorepo's ee/api/agentic_provisioning/views.py, or the provisioning signup call will reject the unknown scopes.
  2. Grant both scopes on the PostHog OAuth application in both regions (US / EU), or read-data-schema still fails at runtime.

Test plan

  • pnpm build — passes
  • pnpm test — 811 tests pass (52 suites)
  • pnpm fix — formatting clean
  • Additive scopes only; no behavior change beyond requesting the scopes.

Created with PostHog Code

Add a README "OAuth Scopes" section documenting the full scope set the
wizard's main basic integration program requests during the OAuth login
flow, with a copy-pasteable list for granting scopes on the OAuth
application in each region.

Add `notebook:write` to `WIZARD_OAUTH_SCOPES` in constants.ts so the code
actually requests the scope it now documents (the OAuth app was granted
`notebook:write` in both US and EU for the notebooks MCP tools), and add a
reverse pointer in its header comment back to the README.

Plant a note in the wizard-development MAINTAINING-SKILLS reference so
future agents keep the README scopes table in sync with the constant
whenever scopes change.

Generated-By: PostHog Code
Task-Id: e5fcb78f-1b7c-4ce5-8ba4-c825400b2d98
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@gewenyu99 gewenyu99 changed the title docs: Document required OAuth scopes for the basic integration program feat: request read-data-schema + notebook OAuth scopes and document the scope set Jun 5, 2026
@edwinyjlim edwinyjlim marked this pull request as ready for review June 5, 2026 15:52
edwinyjlim and others added 5 commits June 5, 2026 11:52
main moved `notebook:write` into `WIZARD_PROVISIONING_SCOPES`, which is
spread into `WIZARD_OAUTH_SCOPES`. Drop the now-redundant explicit
`notebook:write` from the OAuth scope array and remove it from the header
comment's "login-only / not in the provisioning allowlist" list, since it
is now a provisioning scope. Reorder the README scope table to mirror the
constant (provisioning scopes first, then the login-only and
read-data-schema scopes). No change to the requested scope set —
`getOAuthScopesForProgram` already deduped the entry.

Generated-By: PostHog Code
Task-Id: 05a4e027-8271-4393-8df2-f5456649ee4f
The wizard agent uses the read-data-schema MCP tool to discover real
event/property names instead of guessing from capture() calls in code.
That tool is gated on event_definition:read + property_definition:read,
which the base scope set never requested — so schema discovery failed.

The previous version of this branch added the two scopes only to
WIZARD_OAUTH_SCOPES (the OAuth login path), leaving WIZARD_PROVISIONING_SCOPES
untouched. New users who sign up *through* the wizard run the agent with the
provisioning token, so read-data-schema stayed broken for them.

Add the two scopes to WIZARD_PROVISIONING_SCOPES instead. WIZARD_OAUTH_SCOPES
spreads the provisioning set, so both the signup and login paths now request
them with no duplication. Update provisioning.test.ts accordingly.

Also make the docs honest: the requested scope set is program-dependent
(PROGRAM_SCOPE_ADDITIONS layers extra read scopes for programs like the MCP
tutorial), so the README now documents the base set plus that layering, and
both prerequisites — backend ALLOWED_PROVISIONING_SCOPES and per-region OAuth
app grants — are called out in the README, the constants comments, and
MAINTAINING-SKILLS.md.

Prerequisites before this ships (out of repo):
- add event_definition:read + property_definition:read to
  ALLOWED_PROVISIONING_SCOPES in ee/api/agentic_provisioning/views.py, or the
  provisioning signup call will reject the unknown scopes;
- grant both scopes on the PostHog OAuth application in US and EU.

Generated-By: PostHog Code
Task-Id: 05a4e027-8271-4393-8df2-f5456649ee4f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants