8000 Can't deserialize DynamicTemplate due to JSON conversion error starting with 8.18.0 · Issue #8577 · elastic/elasticsearch-net · GitHub
[go: up one dir, main page]

Skip to content
Can't deserialize DynamicTemplate due to JSON conversion error starting with 8.18.0 #8577
Closed
OrchardCMS/OrchardCore
#18042
@Piedone

Description

@Piedone

Elastic.Clients.Elasticsearch version:

8.18.2

Elasticsearch version:

8.18.2

.NET runtime version:

.NET SDK 9.0.301

Operating system version:

Windows 11 Pro 24H2

Description of the problem including expected versus actual behavior:
Updating Elastic.Clients.Elasticsearch from 8.17.4 to 8.18.2 brings breaking changes in TypeMapping.DynamicTemplates, see the diff here. If you adapt your code, then you'll get a "System.MissingMethodException: 'Constructor on type 'System.String' not found.'" exception from Elastic.Clients.Elasticsearch.Serialization.KeyValuePairConverterFactory. I see no way of fixing this from the consumer code.

Steps to reproduce:

  1. Specify DynamicTemplates via TypeMapping for your index via TypeMapping.DynamicTemplates.Add(new KeyValuePair<string, DynamicTemplate>("mypattern", template));. This is buried down in the Elasticsearch feature of Orchard Core, but the concrete code we use is from here.l
  2. Serialize the object for storage with Elastic.Transport.Serializer. Concrete code is here.
  3. Deserialize the previously stored JSON with Elastic.Transport.Serializer. Concrete code is here. Observe that a "System.MissingMethodException: 'Constructor on type 'System.String' not found.'" exception is thrown from Elastic.Clients.Elasticsearch.Serialization.KeyValuePairConverterFactory, see below. DynamicTemplates must be specified as KeyValuePair<string, DynamicTemplate>, thus the keys must be string, and System.String doesn't contain a constructor that takes a string. So, I don't see this being possible to work around from the consumer code.

Image

I realize this is far from a minimal repro, but if you need any other information, please let me know.

Expected behavior
No exception is thrown and deserialization completes, as it did on 8.17.4. BTW here are the code changes necessary between 8.17.4 and 8.18.0. These are BTW breaking changes, so I think they shouldn't have been released as a minor version.

Provide ConnectionSettings (if relevant):

Not relevant.

Provide DebugInformation (if relevant):

I don't think it's relevant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0