Skip to content

fix: initialize model factories before concurrent reuse - #8347

Open
RKS (rksharma-owg) wants to merge 6 commits into
microsoft:mainfrom
rksharma-owg:codex/fix-model-factory-initialization
Open

RKS (rksharma-owg) wants to merge 6 commits into
microsoft:mainfrom
rksharma-owg:codex/fix-model-factory-initialization

Conversation

@rksharma-owg

@rksharma-owg RKS (rksharma-owg) commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #6854.

Parallel endpoints can reuse a response model before its discriminator factory exists. The backward-compatible C#/Go response path immediately clones that factory and can throw Sequence contains no matching element.

Initialize the factory signature alongside serialization members before publishing the model. Populate discriminator mappings after property discovery as before. No waits or lifecycle locks are added. The changelog entry remains under Unreleased.

Validation for be0b847e5b0ecfdb2509994fa35e1ccfc870ac0c against main 1b6cb197f1ba48f4298477eaab4e6be73b13294b:

Existing upstream suppressions and analyzers are unchanged. Approval-held upstream workflows remain separate from completed fork validation.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 03: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 review overview

🟢 Approval recommended

The narrowly scoped lifecycle change preserves existing mapping behavior and is covered by a deterministic regression test.

Review effort: Balanced
Findings: None

What changed in this PR

Moves model factory initialization before model publication to prevent concurrent C#/Go backward-compatible response generation failures.

Changes:

  • Initializes factory signatures before shared-model reuse.
  • Populates discriminator mappings after property discovery.
  • Adds deterministic concurrency regression coverage and changelog documentation.
File Description
src/​Kiota.Builder/​KiotaBuilder.cs Fixes concurrent factory availability.
tests/​Kiota.Builder.Tests/​KiotaBuilderTests.ModelFactory.cs Tests controlled C#/Go interleaving.
CHANGELOG.md Documents the fix.

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

Copilot AI balanced review requested due to automatic review settings October 7, 2026 14:02

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 initialization ordering fixes the reported race and is covered by focused concurrency tests.

Review effort: Balanced
Findings: None

Copilot AI balanced review requested due to automatic review settings October 8, 2026 03:48

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.

🟢 Approval recommended

The targeted initialization change resolves the race while preserving mapping behavior and includes focused regression coverage.

0 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@rksharma-owg
RKS (rksharma-owg) marked this pull request as ready for review October 8, 2026 15:48
@rksharma-owg
RKS (rksharma-owg) requested a review from a team as a code owner October 8, 2026 15:48
@rksharma-owg

Copy link
Copy Markdown
Contributor Author

The failed Notion/PHP job reports StringOrStringArray::setString() receiving array<mixed> where PHPStan expects array<string>|null. This is the collection-nullability issue tracked in microsoft/kiota-php#117; main now includes the scoped workaround from #8377. The same error appeared on both #8347 and #8367. I have not changed their implementations or weakened PHPStan to work around it.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 18:54
auto-merge was automatically disabled October 14, 2026 18:54

Head branch was pushed to by a user without write access

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.

🟢 Approval recommended

The targeted initialization change addresses the reported race, includes regression coverage, and has no identified blocking issues.

0 open findings

🧠 Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 21, 2026 02:25
@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.

🟢 Approval recommended

The targeted initialization change addresses the reported race, with regression coverage for both affected languages and no unresolved findings.

No open issues 🎉

Review effort: Balanced

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.

Random error during client generation: Sequence contains no matching element

3 participants