Skip to content

Maximum allowed coordinate cycle depth was exceeded #8215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rumeshat opened this issue Apr 2, 2025 · 3 comments
Closed

Maximum allowed coordinate cycle depth was exceeded #8215

rumeshat opened this issue Apr 2, 2025 · 3 comments

Comments

@rumeshat
Copy link

rumeshat commented Apr 2, 2025

Product

Hot Chocolate

Version

15.0

Link to minimal reproduction

N.A

Steps to reproduce

We are getting an error "Maximum allowed coordinate cycle depth was exceeded" as soon as deployed in Production Environment. However, the same works fine in Development environments.

Any idea about what could be the reason ?

What is expected?

It should have the same behaviour

What is actually happening?

as change on environment

Relevant log output

Additional context

No response

@michaelstaib
Copy link
Member

michaelstaib commented Apr 2, 2025

Thanks for reaching out! A couple of quick notes:

  1. Please do not open a bug for general questions. If you need help, head over to our community Slack.
  2. This is not a bug — it's caused by a security feature that is configurable.

📏 MaxAllowedFieldCycleDepthRule

By default, Hot Chocolate enforces a cycle depth limit of 3 to prevent malicious or overly complex queries. This limit is applied globally unless configured otherwise.

You can override this behavior by removing the default rule and configuring a custom one:

builder
    .AddGraphQLServer()
    .RemoveMaxAllowedFieldCycleDepthRule()
    .AddMaxAllowedFieldCycleDepthRule(defaultCycleLimit: 6);

If you want finer control, you can set a global default and define custom limits per coordinate like so:

builder
    .AddGraphQLServer()
    .RemoveMaxAllowedFieldCycleDepthRule()
    .AddMaxAllowedFieldCycleDepthRule(
        defaultCycleLimit: 3,
        coordinateCycleLimits: [(new SchemaCoordinate("Human", "relatives"), 10)]);

This configuration allows coordinate repetition of 3 in general, but for the specific field Human.relatives, it allows repetition up to 10 times.

As a result, the following query would be allowed, even though it repeats Human.relatives four times in a single path:

{
  humanById(id: 1) {
    relatives {
      relatives {
        relatives {
          relatives {
            name
          }
        }
      }
    }
  }
}

If you have further questions, feel free to continue the conversation in Slack! 👍

@rumeshat
Copy link
Author

rumeshat commented Apr 3, 2025

@michaelstaib Thanks for your reply. You are on the spot. Actually, we were using version 14, and it appears its giving this. But the issue was not there in both version 13 and 15.

@michaelstaib
Copy link
Member

It's also 15 but only when you run in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants