Skip to content

codegen: regenerated code fails to build — schemas barrel duplicates + stale serverless-apis.ts #352

Description

@flobernd

Discovered while verifying the weekly codegen workflow end-to-end (PR #348, workflow_dispatch run 26101462707). After a fresh npm run codegen:{es,cloud,kibana} against the latest elastic/elastic-client-generator-js@main, the subsequent npm run build fails with two distinct categories of TypeScript errors. Both are real drift between the regenerated output and the cli's current expectations — not workflow infrastructure problems.

Reproduce

git checkout main
npm ci
CODEGEN_GENERATOR_REF=main npm run codegen:es
CODEGEN_GENERATOR_REF=main npm run codegen:cloud
CODEGEN_GENERATOR_REF=main npm run codegen:kibana
npm run build

Category 1 — 149× TS2308 duplicate exports in src/es/apis/schemas/_index.ts

The regenerated schemas barrel does export * from many per-endpoint files that re-export overlapping common symbols (Id, RequestBase, TODO, Duration, integer, long, ExpandWildcards, Refresh, all the Watcher* types, …). Example errors:

src/es/apis/schemas/_index.ts(586,1): error TS2308: Module './async_search_get.ts' has already exported a member named 'SortResults'.
src/es/apis/schemas/_index.ts(586,1): error TS2308: Module './async_search_get.ts' has already exported a member named 'StandardRetriever'.
src/es/apis/schemas/_index.ts(586,1): error TS2308: Module './watcher_execute_watch.ts' has already exported a member named 'WatcherActions'.
... (149 total)

Likely culprits:

  • The generator's zod-schemas output now inlines common types into every per-endpoint file (and the barrel naively re-exports * from all of them), or
  • scripts/build-api-manifest.mjs / the equivalent for schemas needs to switch to explicit export { … } from './foo.ts' rather than blanket export *.

Worth comparing the current generator output for output/ against what src/es/apis/schemas/_index.ts used to look like on main to find when the divergence appeared.

Category 2 — TS2307 missing modules in src/cloud/serverless-apis.ts

src/cloud/serverless-apis.ts:12  Cannot find module './apis/elasticsearch-projects.ts'
src/cloud/serverless-apis.ts:13  Cannot find module './apis/linked-candidate-projects.ts'
src/cloud/serverless-apis.ts:14  Cannot find module './apis/linked-projects.ts'
src/cloud/serverless-apis.ts:15  Cannot find module './apis/observability-projects.ts'
src/cloud/serverless-apis.ts:16  Cannot find module './apis/regions.ts'
src/cloud/serverless-apis.ts:17  Cannot find module './apis/security-projects.ts'
src/cloud/serverless-apis.ts:18  Cannot find module './apis/traffic-filters.ts'

src/cloud/serverless-apis.ts declares itself auto-generated ("This file was auto generated by elastic/elastic-client-generator-js. DO NOT MODIFY IT BY HAND.") but scripts/codegen.mjs's generateCloud only copies output/cloud/apis/** and output/cloud/apis.tsserverless-apis.ts isn't part of the flow, so it has stayed pinned to the file layout the generator produced when the file was first checked in. Either:

  • The generator dropped/renamed those per-resource files and serverless-apis.ts should be removed (and its callers updated), or
  • The generator still produces an equivalent serverless barrel and scripts/codegen.mjs is missing the copy step.

Suggested next steps

  1. Look at the generator's current output/cloud/ after running npm run cli-cloud and decide which of the two cases above applies, then update scripts/codegen.mjs (and possibly the upstream generator) accordingly.
  2. For the schemas barrel: inspect output/ after npm run zod and choose between (a) regenerating the barrel with explicit named re-exports or (b) fixing the upstream barrel emission to dedupe.
  3. Once both are resolved, re-run gh workflow run codegen.yml --ref main to confirm the cron is healthy end-to-end.

Related: PR #348 (workflow auth + heap fix), upstream elastic/elastic-client-generator-js#181 (now fixed).

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions