Skip to content

Fix TypeScript derived model serialization dispatch - #8241

Open
Shubham Padkonde (Shubham-Padkonde) wants to merge 10 commits into
microsoft:mainfrom
Shubham-Padkonde:fix/typescript-derived-serialization
Open

Shubham Padkonde (Shubham-Padkonde) wants to merge 10 commits into
microsoft:mainfrom
Shubham-Padkonde:fix/typescript-derived-serialization

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor

Fixes #6777.

A base serializer dispatches to a derived serializer with isSerializingDerivedType = true, but the derived serializer immediately returns when that flag is set. This drops the derived properties. Removing that guard alone can also cause duplicate property writes when invoking a derived serializer directly.

Dispatch to a mapped serializer before writing properties and return its result. When serializing inherited properties, pass the flag to suppress further discriminator dispatch while still writing the parent fields. Ignore mappings back to the current type so a base-type discriminator value cannot recurse into itself.

Update the writer regressions for the null guard, parent call and discriminator dispatch; the discriminator test also covers a self-mapping and verifies dispatch precedes property writes. Existing literal-escaping checks remain passing.

Developed with Codex assistance.

Validation:

  • Three updated writer regressions fail against the original implementation. All 189 TypeScript writer/refiner tests pass after the change.
  • The attached schema from Typescript client generation doesn't handle allOf correctly when serializing, again in 1.28.0 #6777 reproduces dropped derived fields in a generated-client runtime check before the fix.
  • Afterward, the generated client compiles with TypeScript 5.8.2 and Kiota packages 1.0.0-preview.107. An extension of the attachment covers ten runtime cases: base/direct derived calls, three-level inheritance, self-mapping, unknown/missing discriminators, plus null controls. A recording writer verifies exact-once field writes; the real JSON writer verifies the serialized values and absence of duplicate keys. No HTTP requests were sent.
  • .NET 10 generator build and scoped C# formatting verification pass. The generator build emits worktree SourceLink warnings.

@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 supplied review assessments indicate the changes are complete and approval-ready.

Review effort: Lite
Findings: None

What changed in this PR

Fixes TypeScript derived-model serialization by preserving inherited and derived properties without duplicate writes or recursive dispatch.

Changes:

  • Dispatches mapped serializers before local property writes.
  • Prevents self-mapping recursion.
  • Updates regression tests and changelog documentation.
File Summary
tests/​Kiota.Builder.Tests/​Writers/​TypeScript/​CodeFunctionWriterTests.cs Expands serializer regression coverage.
src/​Kiota.Builder/​Writers/​TypeScript/​CodeFunctionWriter.cs Corrects discriminator and inheritance serialization flow.
CHANGELOG.md Documents the TypeScript serialization 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:31

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:24

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 review requested due to automatic review settings September 23, 2026 14:47

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 23, 2026 17:16

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 24, 2026 01:03
@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 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

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 client generation doesn't handle allOf correctly when serializing, again in 1.28.0

3 participants