Skip to content

fix: preserve TypeScript builders for trailing-slash paths - #8251

Open
Shubham Padkonde (Shubham-Padkonde) wants to merge 11 commits into
microsoft:mainfrom
Shubham-Padkonde:fix/typescript-trailing-slash
Open

Shubham Padkonde (Shubham-Padkonde) wants to merge 11 commits into
microsoft:mainfrom
Shubham-Padkonde:fix/typescript-trailing-slash

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

Fixes #7861.

Request builders for /token and /token/ occupy the same namespace but were placed in separate CodeFiles. Both files normalize to index.ts, so writing one overwrote the other, losing request metadata and inline model serializers/factories. Group the request-builder files before import cleanup so each output path contains all its declarations.

When several builders share a file, select the URI template belonging to the metadata's original request-builder class rather than the first template in that file. Update hand-built writer test fixtures to supply the same original-class association as generated constants.

Validation:

  • New builder/refiner/writer regression fails before the fix (two files targeting one output path) and passes after it. Covers both request builders, inline body/response interfaces, and each metadata constant's own URI template.
  • All 189 TypeScript-focused tests pass, including existing literal-escaping tests.
  • .NET 10 CLI build passes with four environment-related SourceLink warnings.
  • Regenerated the full Pipedrive schema: TypeScript 5.8.2 compilation passes. A runtime export check fails on the original output and passes with the fix; the actual Kiota proxy builds /oauth/token/ with the expected form-encoded grant_type and refresh_token.
  • A minimal generated client preserves distinct /token and /token/ URLs and its JSON request body.
  • Scoped formatting verification passes.
  • No external HTTP requests were sent by the runtime checks.

Prepared with Codex assistance.

@baywet

Copy link
Copy Markdown
Member

Shubham Padkonde (@Shubham-Padkonde) your behaviour is disruptive, opening about 30 PRs on the repos in a couple of hours time, most likely code that was AI generated and not tested/reviewed, will only clog our review pipeline. Please stop opening additional pull requests and work on the comments added to existing ones. We have turned on pull requests limits on this repository, and will proceed to blocking you at the organization level if additional pull requests are opened on other repositories before the already opened ones are reviewed and closed/or merged.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The changes align with TypeScript path normalization behavior, add targeted regression coverage, and the updated writer logic correctly preserves per-builder URI template associations without introducing new unsafe literal emissions.

Review effort: Lite
Findings: None

What changed in this PR

This PR fixes a TypeScript codegen edge case where request builders for paths that differ only by a trailing slash (e.g., /token and /token/) end up targeting the same emitted file (index.ts), causing one builder’s declarations (including inline model serializers/factories and request metadata) to be overwritten.

Changes:

  • Group TypeScript request-builder CodeFiles per namespace before import cleanup so all declarations that normalize to the same output file are written together.
  • Ensure each requests-metadata constant references the URI-template constant associated with its own original request-builder class (via OriginalCodeElement), not the first template in the file.
  • Add/adjust tests to cover the trailing-slash collision scenario and validate correct URI-template selection per metadata constant.
File Description
src/​Kiota.Builder/​Refiners/​TypeScriptRefiner.cs Adds request-builder file grouping to prevent index.ts overwrite when multiple builders normalize to the same output path.
src/​Kiota.Builder/​Writers/​TypeScript/​CodeConstantWriter.cs Fixes URI-template association for request metadata by matching on OriginalCodeElement.
tests/​Kiota.Builder.Tests/​Writers/​TypeScript/​CodeConstantWriterTests.cs Updates fixtures to set OriginalCodeElement on URI-template constants to reflect production behavior.
tests/​Kiota.Builder.Tests/​KiotaBuilderTests.TypeScriptTrailingSlash.cs Adds regression test ensuring both trailing-slash builders and their inline types survive, and metadata uses the correct template constant.
CHANGELOG.md Documents the TypeScript trailing-slash preservation fix.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 21, 2026 16:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 22, 2026 09:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI review requested due to automatic review settings September 22, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@baywet

Copy link
Copy Markdown
Member

Shubham Padkonde (@Shubham-Padkonde) this PR is conflicting, would you mind handling the conflicts when you have a minute please?

Copilot AI review requested due to automatic review settings September 23, 2026 12:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

A critical merged-import collision issue and a moderate regression coverage gap remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)

Comment thread src/Kiota.Builder/Refiners/TypeScriptRefiner.cs
Copilot AI review requested due to automatic review settings September 23, 2026 13:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor Author

Fixed the merged-file import/declaration collision in 2de1c6a. After grouping request-builder files, the refiner now aliases child imports against the complete set of declarations in the merged file.

Added an OpenAPI regression with /token and /token/, where the latter returns a model named TokenRequestBuilder. The regression fails before the fix because the model import has no alias and passes afterward. All 176 TypeScript writer/refiner tests and 8 selected generation cases pass; the .NET 10 build has zero warnings/errors, and scoped whitespace formatting plus git diff --check pass. This follow-up was not validated by recompiling the full Pipedrive client.

Prepared and tested with OpenAI Codex assistance.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The fix and regression coverage address the trailing-slash collision and preserve builder-specific metadata.

Review effort: Lite
Findings: None

Resolved since last review (1)

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.

Copilot AI review requested due to automatic review settings September 23, 2026 17:17
@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will take a look shortly.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.

Copilot AI review requested due to automatic review settings September 24, 2026 01:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will take a look shortly.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.

Copilot AI review requested due to automatic review settings September 25, 2026 01:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will take a look shortly.

@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will take a look shortly.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged.

Copilot AI review requested due to automatic review settings September 25, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

Conflicts have been resolved. A maintainer will take a look shortly.

This branch has not been deployed

No deployments
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.

[Typescript] "No matching export ..." error for PIPEDRIVE.COM api

3 participants