fix: unwrap single-entry anyOf/oneOf nullable reference wrappers#7531
Merged
gavinbarron merged 5 commits intomainfrom Apr 1, 2026
Merged
fix: unwrap single-entry anyOf/oneOf nullable reference wrappers#7531gavinbarron merged 5 commits intomainfrom
gavinbarron merged 5 commits intomainfrom
Conversation
Kiota hits a StackOverflowException when generating from OpenAPI specs that use single-entry anyOf wrappers for nullable references to self-referential schemas. This pattern is valid OpenAPI 3.0 and is now produced by newer versions of hidi, which collapses the previous two-entry anyOf into a cleaner single-entry form that kiota had no handler for. - Unwrap single-entry anyOf/oneOf ref wrappers (no discriminator, no own properties) early in CreateModelDeclarations - Add ThreadLocal<HashSet<string>> discriminator cycle guard in AddModelClass - Add Monitor.IsEntered reentrance guard in ModelClassBuildLifecycle with warning log on activation - Add ThreadLocal<int> depth guard (max 50) in CreatePropertiesForModelClass as safety net for patterns not caught by the unwrap - Add regression tests for self-referential nullable ref unwrapping and discriminator-bearing wrapper preservation Closes #7530 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
baywet
previously approved these changes
Mar 25, 2026
Member
|
put together #7532 to unblock this |
Contributor
Author
|
@copilot run dornet format |
…in tests Agent-Logs-Url: https://github.com/microsoft/kiota/sessions/b7ce9587-9a01-4d10-a7cf-8fd0b3ffea35 Co-authored-by: gavinbarron <7122716+gavinbarron@users.noreply.github.com>
Contributor
baywet
approved these changes
Apr 1, 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.
CreateModelDeclarationsNullableReferenceWrapperUnwrapsToReferencedSchemaAsyncandNullableReferenceWrapperWithDiscriminatorIsNotUnwrappedAsyncdotnet format- fix xUnit1051 warnings by usingTestContext.Current.CancellationTokenin new tests