Skip to content

chore(codegen): daily schema refresh (2026-07-29) - #106

Draft
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-07-29
Draft

chore(codegen): daily schema refresh (2026-07-29)#106
timgl wants to merge 1 commit into
mainfrom
posthog-code/schema-refresh-2026-07-29

Conversation

@timgl

@timgl timgl commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Why

Automated daily OpenAPI schema refresh. Keeps the typed client (src/generated/api.d.ts) in sync with the live PostHog API and absorbs upstream schema drift before it breaks downstream consumers.

Spec diff size

src/generated/api.d.ts: +3600 / −1551 lines (filtered spec; trimmed to the allowlisted operations in openapi-filter.yaml). The regenerated types were driven entirely by pnpm codegen — no hand edits.

New operationIds added to the filter

The endpoints resource moved in the live spec, from /api/environments/{environment_id}/endpoints/ to /api/projects/{project_id}/endpoints/, and its operationIds were renamed environments_endpoints_*endpoints_*. Added to openapi-filter.yaml:

  • endpoints_list
  • endpoints_create
  • endpoints_retrieve
  • endpoints_update
  • endpoints_partial_update
  • endpoints_destroy

No brand-new resource families were added. The vast majority of live-spec operationIds not in the filter are unmanaged product/admin/debug endpoints outside this project's IaC surface (dashboards, insights, feature flags, actions, cohorts, endpoints, event definitions, property groups, event schemas, experiments + holdouts/saved-metrics, environments). The daily refresh intentionally does not auto-expand the managed surface to new families or auxiliary sub-endpoints (e.g. *_activity_retrieve, *_bulk_update_tags_create, dashboards_collaborators_*) — those are left out as not worth managing here.

Resources touched

Schema-name drift patched in the affected Zod/type projections (minimal edits, no refactors):

  • endpoint (src/resources/endpoint/client.ts) — repointed all CRUD paths to /api/projects/{project_id}/endpoints/ and the path param environment_idproject_id. The EndpointResponse / PaginatedEndpointResponseList schemas still exist upstream; they had only been pruned as orphans once the old operationIds vanished.
  • dashboard (src/resources/dashboard/client.ts) — PATCH body schema PatchedDashboardPatchedPatchedDashboardOpenApi.
  • experiment (src/resources/experiment/client.ts) — write body ExperimentExperimentWrite, PATCH body PatchedExperimentPatchedExperimentWrite, list response PaginatedExperimentListPaginatedExperimentBasicList.

pnpm typecheck and pnpm test (291 tests) pass.

Unresolved drift / needs a human

  • The old endpoint operationIds environments_endpoints_* disappeared from the live spec (moved, not deleted). Per refresh policy we do not auto-remove disappeared operationIds — they are kept in openapi-filter.yaml (now matching nothing, with an explanatory comment) and flagged here for a human to delete.
  • Pre-existing (not introduced by this PR): pnpm lint and pnpm format:check already fail on main across many files, including dashboard/client.ts and experiment/client.ts. Left untouched to keep this diff minimal; worth a separate cleanup pass.

TaskRun

Task-Id: feb08c8e-e3d5-41bd-82fb-51c2088d3c7d


Created with PostHog Code

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI schema and
absorb schema drift across managed resources.

- endpoints resource moved /api/environments/{id}/endpoints/ -> /api/projects/{id}/endpoints/
  (operationIds environments_endpoints_* -> endpoints_*); update filter + client paths
- dashboards PATCH body schema renamed PatchedDashboard -> PatchedPatchedDashboardOpenApi
- experiments write schemas renamed Experiment/PatchedExperiment -> ExperimentWrite/PatchedExperimentWrite
  and list response PaginatedExperimentList -> PaginatedExperimentBasicList

Generated-By: PostHog Code
Task-Id: feb08c8e-e3d5-41bd-82fb-51c2088d3c7d
@timgl
timgl requested a review from pl July 29, 2026 08:01
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.

1 participant