Skip to content

.Net: OpenApi function generation hits JSON serialization error for deep structures #4991

@zengin

Description

@zengin

Describe the bug
Microsoft Graph's drive item content endpoint /drive/root/children/{driveItem-id}/content fails to generate a function in Semantic Kernel due to default serialization setting of depth of 64.

To Reproduce
It is easier to reproduce the error with API Manifest plugins due to availability of slicing. It uses OpenAPI path for function generation, so I built the repro on top of #4961, diff is here

Steps:

  1. gh repo clone zengin/semantic-kernel
  2. git checkout zengin/json-depth-test
  3. cd semantic-kernel/dotnet/samples/KernelSyntaxExamples
  4. dotnet test --filter Example80_ApiManifest --logger "console;verbosity=detailed"
  5. Observe the following error:
Error Message:
   System.AggregateException : Plugin creation failed for DriveItemPlugin (The maximum configured depth of 64 has been exceeded. Cannot read next JSON object. Path: $ | LineNumber: 10780 | BytePositionInLine: 134.)
---- System.Text.Json.JsonException : The maximum configured depth of 64 has been exceeded. Cannot read next JSON object. Path: $ | LineNumber: 10780 | BytePositionInLine: 134.
-------- System.Text.Json.JsonReaderException : The maximum configured depth of 64 has been exceeded. Cannot read next JSON object. LineNumber: 10780 | BytePositionInLine: 134.

Expected behavior
A plugin function is generated for drive item content endpoint

Additional context
Solution here

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codetriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions