Skip to content

FieldValidationInstrumentation.beginExecuteOperation does not forward the state and throws assertionerror #3065

@kfwerf

Description

@kfwerf

Hi good folks of graphql-java!

We are trying to switch from version 19.* to version 20.* of the library. However, in doing so we ran into some issues with our local validator instrumentation. I didn't see a bug ticket for this yet, so please correct me if I somehow missed it!

Describe the bug
In version 20.0 we cannot use the FieldValidationInstrumentation anymore. This is due to it using a method that throws a deprecated warning. Considering FieldValidationInstrumentation not deprecated, we think this was a mistake. The FieldValidationInstrumentation fails to forward the state to the super.beginExecuteOperation(parameters), which should be super.beginExecuteOperation(parameters, state). Due to this it gives an assertion error;

graphql.AssertException: Internal error: should never happen: The deprecated beginExecuteOperation was calledgraphql.AssertException: Internal error: should never happen: The deprecated beginExecuteOperation was called at graphql.Assert.assertShouldNeverHappen(Assert.java:53) at graphql.execution.instrumentation.SimplePerformantInstrumentation.beginExecuteOperation(SimplePerformantInstrumentation.java:91) at graphql.execution.instrumentation.fieldvalidation.FieldValidationInstrumentation.beginExecuteOperation(FieldValidationInstrumentation.java:46) at graphql.execution.instrumentation.ChainedInstrumentation.lambda$beginExecuteOperation$3(ChainedInstrumentation.java:143) 

TL;DR;
FieldValidationInstrumentation.beginExecuteOperation should forward the state in the method -> super.beginExecuteOperation(parameters, state)

To Reproduce
If you run something like this; with a active query it will result in a assertion error.

import graphql.GraphQLError;
import graphql.execution.instrumentation.ChainedInstrumentation;
import graphql.execution.instrumentation.Instrumentation;
import graphql.execution.instrumentation.fieldvalidation.FieldValidation;
import graphql.execution.instrumentation.fieldvalidation.FieldValidationEnvironment;
import graphql.execution.instrumentation.fieldvalidation.FieldValidationInstrumentation;
import java.util.ArrayList;
import java.util.List;

class Scratch {

  public static void main(String[] args) {
    final var instrumentations = new ArrayList<Instrumentation>();
    instrumentations.add(new FieldValidationInstrumentation(new FieldValidation() {
      @Override
      public List<GraphQLError> validateFields(
          final FieldValidationEnvironment validationEnvironment) {
        return null;
      }
    }));
    final var chained = new ChainedInstrumentation(instrumentations);
  }
}

EDIT: Fix here #3066

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions