Skip to content

fix(sdk-generator): disambiguate operations that infer the same name - #122

Merged
calvin-archastro merged 1 commit into
mainfrom
fix/sdk-generator-operation-name-collisions
Nov 1, 2026
Merged

calvin-archastro merged 1 commit into
mainfrom
fix/sdk-generator-operation-name-collisions

Conversation

@calvin-archastro

Copy link
Copy Markdown
Contributor

Problem

After refreshing the platform spec (#121), regenerating archastro-js fails to compile: PUT /api/v1/task_epics/{epic}/drafts and PUT /api/v1/task_epics/{epic}/drafts/{key} both infer the operation name replace on the same drafts resource, emitting two replace methods (TS2393: Duplicate function implementation). Python/other backends share the same inferred names.

Change

resolveOperationNameCollisions in resource-inferrer.ts runs after the tree is built. Within one resource, the shallowest path (then alphabetical) keeps the inferred name, so existing SDK surfaces are unchanged. Others get a By<LastPathParam> suffix (replaceByKey), with a numeric fallback. Deterministic regardless of operation order.

Scope / risk / testing

Generator only. Low risk: only affects resources that previously emitted duplicate names (invalid code). New tests in __tests__/frontend/resource-inferrer.test.ts; npm run build, npm run lint, npm test pass locally; CI runs them on Node 20/22.

Follow-up: release a new @archastro/sdk-generator so downstream @latest picks this up.

🤖 Generated with Claude Code

PUT /x/{epic}/drafts and PUT /x/{epic}/drafts/{key} both inferred
"replace" on one resource, producing duplicate methods (TS2393) in the
generated SDK. The shallowest path keeps the inferred name; others get a
ByParam suffix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@calvin-archastro
calvin-archastro merged commit 5124f79 into main Nov 1, 2026
2 checks passed
@calvin-archastro
calvin-archastro deleted the fix/sdk-generator-operation-name-collisions branch November 1, 2026 04:21
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