Skip to content

Error with fusion: An item with the same key has already been added, when require the same field on type extension #6993

Closed

Description

Product

Hot Chocolate

Version

14.0.0-p66

Link to minimal reproduction

https://github.com/rowe-stamy/FusionBug

Steps to reproduce

Launch all three projects (ServiceA, ServiceB and Gateway) and run the problematic query against the gateway:

query problem {
  foos {
    commonField
    barByCommonField {
      barField
    }
    fizzByCommonField {
      fizzField
    }
  }
}

What is expected?

The expected outcome should be data as follows:

{
  "data": {
    "foos": [
      {
        "commonField": "commonFieldValue",
        "barByCommonField": {
          "barField": "barFieldValue"
        }
        "fizzByCommonField": {
          "fizzField": "barFieldValue"
        }
      }
    ]
  }
}

What is actually happening?

I am getting a "Unexpected Execution Error"
with the following message:
"An item with the same key has already been added. Key: Foo_commonField"

Relevant log output

at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) 
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value) 
at HotChocolate.Fusion.Planning.Pipeline.FieldRequirementsPlannerMiddleware.ResolveVariablesInContext(QueryPlanContext context, FieldContext fieldContext, SelectionExecutionStep executionStep, ObjectFieldInfo fieldInfo, ISelectionSet selectionSet, ResolverDefinition resolver) 
at HotChocolate.Fusion.Planning.Pipeline.FieldRequirementsPlannerMiddleware.ResolveRequirementsForSelectionResolvers(QueryPlanContext context, FieldContext fieldContext, SelectionExecutionStep currentStep, ISelection parentSelection) 
at HotChocolate.Fusion.Planning.Pipeline.FieldRequirementsPlannerMiddleware.Invoke(QueryPlanContext context, QueryPlanDelegate next) 
at HotChocolate.Fusion.Planning.QueryPlanPipelineBuilder.<>c__DisplayClass5_1`1.<Use>b__1(QueryPlanContext context)
at HotChocolate.Fusion.Planning.Pipeline.ExecutionStepDiscoveryMiddleware.Invoke(QueryPlanContext context, QueryPlanDelegate next) 
at HotChocolate.Fusion.Planning.QueryPlanPipelineBuilder.<>c__DisplayClass5_1`1.<Use>b__1(QueryPlanContext context) 
at HotChocolate.Fusion.Planning.QueryPlanner.Plan(IOperation operation) 
at HotChocolate.Fusion.Execution.Pipeline.OperationQueryPlanCompiler.OptimizeOperation(OperationOptimizerContext context) 
at HotChocolate.Execution.Processing.OperationCompiler.CreateOperation(String operationId, OperationDefinitionNode operationDefinition, ObjectType operationType, DocumentNode document, ISchema schema) 
at HotChocolate.Execution.Processing.OperationCompiler.Compile(String operationId, OperationDefinitionNode operationDefinition, ObjectType operationType, DocumentNode document, ISchema schema, IReadOnlyList`1 optimizers, Boolean enableNullBubbling) 
at HotChocolate.Execution.Pipeline.OperationResolverMiddleware.CompileOperation(IRequestContext context, String operationId, OperationDefinitionNode operationDefinition, ObjectType operationType) 
at HotChocolate.Execution.Pipeline.OperationResolverMiddleware.InvokeAsync(IRequestContext context) 
at HotChocolate.Execution.Pipeline.OperationComplexityMiddleware.InvokeAsync(IRequestContext context) 
at HotChocolate.Execution.Pipeline.OperationCacheMiddleware.InvokeAsync(IRequestContext context) 
at HotChocolate.Execution.Pipeline.DocumentValidationMiddleware.InvokeAsync(IRequestContext context) 
at HotChocolate.Execution.Pipeline.DocumentParserMiddleware.InvokeAsync(IRequestContext context) 
at HotChocolate.Execution.Pipeline.DocumentCacheMiddleware.InvokeAsync(IRequestContext context) 
at HotChocolate.Execution.Pipeline.TimeoutMiddleware.InvokeAsync(IRequestContext context) 
at HotChocolate.Execution.Pipeline.ExceptionMiddleware.InvokeAsync(IRequestContext context)"

Additional context

No response

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions