question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

StackOverflow when using SchemaRegistry.GetOrRegister in ISchemaFiler.Apply

See original GitHub issue

Hi,

I’ve got a StackOverflow while using a ISchemaFilter that need to register a new type. The recursion happens because I’m applying the filter to a referenced type, not a top-level type. During the while loop of GetOrRegister, my filter get’s called for type A in which I call GetOrRegister for type B. This loops again on the ‘not-yet-compiled’ types and A it’s still there … and calls again my filter on the A type.

You can reproduce with an endpoint that takes this type as ([FromBody]Command c) signature.

public class Command 
{
    public int A {get ;set; }
    public Data Data {get;set;}
}

public class Data
{
    public int A {get;set;}
    public int B {get;set;}
    public IDictionary<object, object> ComplexFieldForWhichIWantToBuildSchema {get;set;}
}

public Filter : ISchemaFilter
{
    public void Apply(Schema schema, SchemaRegistry schemaRegistry, Type type)
    {
        if (type == typeof(Data))
        {
            var t = typeof(KeyValuePair<string, string>[]);
            schema.properties["ComplexFieldForWhichIWantToBuildSchema"] = schemaRegistry.GetOrRegister(t);
        }
    }
}

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Apr 10, 2017

I’m still seeing this issue in release 5.5.3. In my case I’m attempting to register a previously unregistered type, which might be different from the scenario in the test added in #890. Looks like it is attempting to re-run the SchemaFilters on the same type over & over which is causing the stack overflow exception.

1reaction
domaindrivendevcommented, Oct 18, 2016

See PR #890 which resolves this. Will be available with the upcoming v5.5.0 release

Read more comments on GitHub >

github_iconTop Results From Across the Web

StackOverflow when using SchemaRegistry.GetOrRegister ...
I've got a StackOverflow while using a ISchemaFilter that need to register a new type. The recursion happens because I'm applying the filter...
Read more >
Using Swashbuckle for Asp.net core how can I add a ...
This allows you to apply [ApiExplorerSettings(GroupName = "my_group")] attributes to the manually mapped classes (models, schemas) to s them ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found