Skip to content

.Net: Bug: Microsoft.SemanticKernel.Yaml is incompatible with current YamlDotNet, causing TypeLoadException at runtime #9051

@jphorv-bdo

Description

@jphorv-bdo

Describe the bug
Using KernelFunctionYaml.FromPromptYaml() to deserialize YAML to an SK function in an existing codebase, with an existing dependency on YamlDotNet latest version (16.1.3).

The call to KernelFunctionYaml.FromPromptYaml() results in a TypeLoadException with the message:

Method 'ReadYaml' in type 'Microsoft.SemanticKernel.PromptExecutionSettingsTypeConverter' from assembly 'Microsoft.SemanticKernel.Yaml, Version=1.20.0.0, Culture=neutral, PublicKeyToken=f300afd708cefcd3' does not have an implementation.

It appears to be a breaking change with YamlDotNet 16.0.0, released 7/14/2024, specifically a change to the method signature of IYamlTypeConverter.ReadYaml()

To Reproduce
Steps to reproduce the behavior:

  1. Have a project that references YamlDotNet 16.1.3 and Microsoft.SemanticKernel.Yaml
  2. Call KernelFunctionYaml.FromPromptYaml() with valid (or invalid) YAML.
  3. The TypeLoadException is thrown.

Expected behavior
The call to KernelFunctionYaml.FromPromptYaml() should parse the YAML and if it is valid, return a valid KernelFunction object.

Screenshots
N/A

Platform

  • OS: Windows
  • IDE: Visual Studio 2022
  • Language: .NET 8, C#
  • Source: YamlDotNet 16.1.3, Microsoft.SemanticKernel.Yaml 1.20.0 - 1.21.1

Additional context
The problem occurred while using Microsoft.SemanticKernel.Yaml < 1.20.0 but was not investigated until now.

Metadata

Metadata

Labels

.NETIssue or Pull requests regarding .NET codebugSomething isn't working

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions