Skip to content

chore(codegen): daily schema refresh (2026-07-30) - #107

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

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

Conversation

@timgl

@timgl timgl commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Why

Automated daily OpenAPI schema refresh. The live PostHog spec drifted: a managed resource (endpoints) was renamed and two managed resources had request/response schema renames, so the generated types and a few Zod projections needed reconciling to keep the typed client and pull correct.

Spec diff size

  • src/generated/api.d.ts: +3634 / −1582 lines (17,571 → 19,623 lines after regeneration).
  • Regenerated via pnpm codegen only — the generated file was not hand-edited.

New operationIds added to the filter

Added to openapi-filter.yaml (existing managed endpoints family, renamed upstream):

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

These replace the old environments_endpoints_* operationIds, which the live spec renamed. The endpoint path also moved from /api/environments/{environment_id}/endpoints/ to /api/projects/{project_id}/endpoints/.

Resources touched

  • openapi-filter.yaml — added the six endpoints_* operationIds.
  • src/resources/endpoint/client.ts — repointed all calls to the new /api/projects/{project_id}/endpoints/ path (param project_id). Response schemas (EndpointResponse, PaginatedEndpointResponseList) are unchanged; endpoints_retrieve now returns EndpointVersionResponse, a superset, so toServerEndpoint is unaffected.
  • src/resources/dashboard/client.ts — PATCH body schema renamed PatchedDashboardPatchedPatchedDashboardOpenApi.
  • src/resources/experiment/client.ts — PATCH body schema renamed PatchedExperimentPatchedExperimentWrite; list response type renamed PaginatedExperimentListPaginatedExperimentBasicList.
  • src/resources/experiment/index.ts — the experiments list response narrowed from full Experiment to ExperimentBasic (drops metrics, metrics_secondary, saved_metrics). Added hydrateForPull so pull re-fetches the full experiment and does not silently drop those fields (mirrors the dashboard resource, whose list omits tiles).

pnpm typecheck and pnpm test (291 tests) both pass.

Unresolved drift for a human

  • Dead filter entries: the six environments_endpoints_* lines in openapi-filter.yaml no longer match anything in the live spec (renamed to endpoints_*). Per the no-remove policy they were kept and commented; a human should delete them.
  • Giant "new operationIds" drift list: the filter is an allowlist, so nearly the entire PostHog API shows up as "missing." None of those belong to a currently-managed resource family, and none look worth adopting as new managed resources in this refresh (they are product/admin/analytics endpoints outside this IaC tool's scope), so no new resource families were added. The only genuinely-actionable item was the endpoints rename above.
  • PUT variants intentionally skipped: several managed families now expose *_update (PUT) siblings in the spec (e.g. experiments_update, cohorts_update, event_definitions_update). The client deliberately uses partial_update (PATCH), so these were not added.
  • No operationIds were removed from the filter.

TaskRun

https://us.posthog.com/project/423401/tasks/e3149ff1-5de5-4c27-8cf4-33b456bb0877


Created with PostHog Code

Regenerate src/generated/api.d.ts from the live PostHog OpenAPI spec and
reconcile managed resources with drift in the spec.

- endpoints resource renamed in spec: operationIds moved from
  environments_endpoints_* to endpoints_*, path moved from
  /api/environments/{environment_id}/endpoints/ to
  /api/projects/{project_id}/endpoints/. Added the new operationIds to the
  filter and repointed the endpoint client; left the dead
  environments_endpoints_* filter lines for a human to delete.
- dashboard PATCH body schema renamed PatchedDashboard ->
  PatchedPatchedDashboardOpenApi.
- experiment PATCH body schema renamed PatchedExperiment ->
  PatchedExperimentWrite; list response narrowed from Experiment ->
  ExperimentBasic (PaginatedExperimentBasicList). Added hydrateForPull so
  pull re-fetches full experiments and does not silently drop metrics.

Generated-By: PostHog Code
Task-Id: e3149ff1-5de5-4c27-8cf4-33b456bb0877
@timgl
timgl requested a review from pl July 30, 2026 07:56
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