chore: delete stale versioned clients when regenerating openapi/asyncapi codegen - #2322
Merged
mjuchli-da merged 1 commit intoAug 24, 2026
Conversation
…egen Both generate-openapi-clients.ts and generate-asyncapi-clients.ts write their Canton ledger-api output under core/ledger-client-types/src/generated-clients with the Canton version embedded in the filename (openapi-<version>.ts, -paths.ts, -provider-types.ts, asyncapi-<version>.ts). On every Canton version bump this created a new versioned file without removing the old one -- the repo currently has six versions' worth of these files checked in (3.4.12, 3.5.1, 3.5.8, 3.5.10, 3.5.14), most of them for versions no longer in version-config.json. Add cleanupStaleVersionedFiles(), run before generation, which deletes any openapi-*/asyncapi-* file in that directory whose embedded version isn't one of the currently configured Canton versions across all networks (so generating for one network doesn't delete the other network's current files). Scope note: this fixes the script going forward. It intentionally does NOT delete the already-stale checked-in files or touch core/ledger-client-types/src/index.ts, which still hardcodes openapi-3.4.12/openapi-3.5.1 as the '3.4'/'3.5' LedgerApiVersion union. That '3.4'/'3.5' scheme is load-bearing business logic used well beyond this package (default client versions, version-parsing logic, and hardcoded test fixtures in core/ledger-client, core/asyncapi-client, and wallet-gateway/remote), and both currently supported Canton versions (3.5.10 mainnet, 3.5.14 devnet) are already in the "3.5" family, so picking which patch backs that key -- or restructuring the scheme entirely -- needs a maintainer decision, not a script change. Fixes canton-network#1380 Signed-off-by: ayushsingh82 <ayushsinghmi711@gmail.com>
Contributor
Author
|
@alexmatson-da whenever you have a chance, would appreciate a look at this one. |
mjuchli-da
approved these changes
Aug 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generate-openapi-clients.tsandgenerate-asyncapi-clients.tswrite Canton ledger-api output intocore/ledger-client-types/src/generated-clientswith the Canton version embedded in the filename (openapi-<version>.ts,-paths.ts,-provider-types.ts,asyncapi-<version>.ts). Every Canton version bump created a new versioned file without removing the old one. The repo currently has 6 Canton versions' worth of these files checked in (3.4.12, 3.5.1, 3.5.8, 3.5.10, 3.5.14) -- most no longer referenced byversion-config.jsonat all.Added
cleanupStaleVersionedFiles()(scripts/src/lib/utils.ts), run at the start of both scripts, which deletes anyopenapi-*/asyncapi-*file whose embedded version isn't currently configured for any network (so running for one network doesn't delete the other network's valid file).Scope note
This fixes the scripts going forward. It deliberately does not:
core/ledger-client-types/src/index.ts, which still hardcodesopenapi-3.4.12/openapi-3.5.1as the'3.4'/'3.5'LedgerApiVersionunion.That
'3.4'/'3.5'scheme turned out to be load-bearing business logic well beyond this package -- default client versions and version-parsing logic incore/ledger-clientandcore/asyncapi-client, plus hardcodedcantonVersion: '3.4'test fixtures inwallet-gateway/remote. Both currently supported Canton versions (3.5.10 mainnet, 3.5.14 devnet) are already in the same "3.5" family, so deciding which patch backs that key going forward -- or restructuring the versioning scheme entirely -- needs a maintainer's call, not something a codegen cleanup script should decide. Happy to take that on as a follow-up if a maintainer can weigh in on intent.Fixes #1380
Test plan
tsc -bclean inscripts/eslint/prettier --checkclean on all 3 changed filescleanupStaleVersionedFilesagainst a fixture mirroring the repo's actual file set (all 6 checked-in Canton versions + an unrelated file): confirmed it removes exactly the 3.4.12/3.5.1/3.5.8 files (including.d.ts/.d.ts.map) and keeps 3.5.10/3.5.14 and the unrelated filescript:generate:openapi/script:generate:asyncapiend-to-end (needs network access to fetch specs from GitHub releases) -- the cleanup step itself is verified in isolation above