YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

Support keys longer than 1024 characters

Open mvarendorff2 opened this issue 7 months ago • 0 comments

Is your feature request related to a problem? Please describe.

I have a usecase for parsing pnpm-lock.yaml files using this library. Unfortunately, PNPM does not really seem to be concerned with the spec when it comes to key-length (spec says 1024 is the max, pnpm emitted a key of length >1080 in one of my testcases).

Describe the solution you'd like

I'd love to have a new function on the DeserializerBuilder(), maybe something like .WithMaxKeyLength() that allows defining a larger than the default value when deserializing.

Describe alternatives you've considered

  1. Shortening the keys myself with a regex replace or something like that - I don't have a requirement for accurate keys in this specific case at least not for the long ones
  2. Opening an issue with pnpm to adhere to the spec but given that the keys are relevant for them for faster caching, I am not sure this will have much chance of actually going through

Additional context

Reprocase:

const string yamlString = """
                   '@angular/[email protected](@angular/[email protected](@angular/[email protected]([email protected])([email protected])))(@angular/[email protected](@angular/[email protected](@angular/[email protected]([email protected])([email protected]))([email protected]))(@angular/[email protected]([email protected])([email protected]))([email protected]))(@angular/[email protected](@angular/[email protected]([email protected])([email protected]))([email protected]))(@angular/[email protected]([email protected])([email protected]))(@angular/[email protected](@angular/[email protected](@angular/[email protected]([email protected])([email protected]))([email protected]))(@angular/[email protected]([email protected])([email protected]))(@angular/[email protected](@angular/[email protected](@angular/[email protected]([email protected])([email protected])))(@angular/[email protected](@angular/[email protected]([email protected])([email protected]))([email protected]))(@angular/[email protected]([email protected])([email protected])))([email protected]))(@angular/[email protected](@angular/[email protected](@angular/[email protected]([email protected])([email protected])))(@angular/[email protected](@angular/[email protected]([email protected])([email protected]))([email protected]))(@angular/[email protected]([email protected])([email protected])))([email protected])':
                     dependencies: []
                   """;
var deserializer = new DeserializerBuilder().Build();
var yaml = deserializer.Deserialize<Dictionary<string, object>>(yamlString);

Error:

Unhandled exception. (Line: 1, Col: 1, Idx: 0) - (Line: 1, Col: 1089, Idx: 1088): Exception during deserialization

mvarendorff2 avatar Jul 24 '24 11:07 mvarendorff2