You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Linux executable
Client library/SDK language
Go
Describe the bug
I am trying to auto-generate a client using Kiota but when using anyOf schema type for a property in a responseBody, the generation fails if the property has exactly two elements, at least one of which is nullable.
This bug affects all supported languages at the time of writing (CLI, CSharp, Go, Java, PHP, Python, Ruby, Swift, TypeScript).
I expect the generation to succeed, since this issue only occurs with two items in the list.
It succeeds with one item and with more than two items.
How to reproduce
Given an item in the properties map:
if using anyOf as schema type,
if the number of items in that item's list is 2,
and if at least one of those items is nullable (nullable: true),
and if at least one of those items is NOT an "object" data type (EXCEPT if the other is "array"),
Then the Kiota autogeneration fails with the following critical error:
crit: Kiota.Builder.KiotaBuilder[0]
error generating the client: One or more errors occurred. (Sequence contains no matching element)
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
Change anyOf to oneOf schema type.
Use 1 nullable item.
Use more than 2 nullable items.
Configuration
Ubuntu 22.04 (WSL2) running on Windows 10).
x64.
Do not know if this bug is specific to this configuration.
Debug output
Click to expand log
dbug: Kiota.Builder.KiotaBuilder[0]
kiota version 1.17.0
info: Kiota.Builder.KiotaBuilder[0]
loaded description from local source
dbug: Kiota.Builder.KiotaBuilder[0]
step 1 - reading the stream - took 00:00:00.0078402
dbug: Kiota.Builder.KiotaBuilder[0]
step 2 - parsing the document - took 00:00:00.0943962
dbug: Kiota.Builder.KiotaBuilder[0]
step 3 - updating generation configuration from kiota extension - took 00:00:00.0001202
dbug: Kiota.Builder.KiotaBuilder[0]
step 4 - filtering API paths with patterns - took 00:00:00.0048345
info: Kiota.Builder.KiotaBuilder[0]
Client root URL set to https://foo/api/v1
dbug: Kiota.Builder.KiotaBuilder[0]
step 5 - checking whether the output should be updated - took 00:00:00.0137960
dbug: Kiota.Builder.KiotaBuilder[0]
step 6 - create uri space - took 00:00:00.0028304
dbug: Kiota.Builder.KiotaBuilder[0]
InitializeInheritanceIndex 00:00:00.0032005
crit: Kiota.Builder.KiotaBuilder[0]
error generating the client: One or more errors occurred. (Sequence contains no matching element)
Other information
I am not familiar enough with C# to know where exactly this error would come from in the Kiota source code, but searching for 'sequence contains no matching element' in the Microsoft .NET documentation points to this method:
Hi @matthew-c-hpe ,
Thank you for using kiota and for reaching out.
I authored #5281 to fix this issue. The detailed repro was instrumental to tracking the root cause down. Thanks!
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Linux executable
Client library/SDK language
Go
Describe the bug
I am trying to auto-generate a client using Kiota but when using anyOf schema type for a property in a responseBody, the generation fails if the property has exactly two elements, at least one of which is nullable.
This bug affects all supported languages at the time of writing (CLI, CSharp, Go, Java, PHP, Python, Ruby, Swift, TypeScript).
https://github.com/matthew-c-hpe/kiota-bug-anyof
Expected behavior
I expect the generation to succeed, since this issue only occurs with two items in the list.
It succeeds with one item and with more than two items.
How to reproduce
Given an item in the properties map:
Then the Kiota autogeneration fails with the following critical error:
Sample code can be found below:
https://github.com/matthew-c-hpe/kiota-bug-anyof
Open API description file
https://github.com/matthew-c-hpe/kiota-bug-anyof/blob/main/spec-minimal.yaml
Kiota Version
1.17.0
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
Change anyOf to oneOf schema type.
Use 1 nullable item.
Use more than 2 nullable items.
Configuration
Ubuntu 22.04 (WSL2) running on Windows 10).
x64.
Do not know if this bug is specific to this configuration.
Debug output
Click to expand log
Other information
I am not familiar enough with C# to know where exactly this error would come from in the Kiota source code, but searching for 'sequence contains no matching element' in the Microsoft .NET documentation points to this method:
https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable.single?view=net-8.0
Examples of input which fails/succeeds:
Examples: FAIL
Examples: SUCCESS
The text was updated successfully, but these errors were encountered: