Skip to content

ResultPath: Check object type before casting to int #3765

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

Merged
merged 2 commits into from
Dec 4, 2024

Conversation

alex-cova
Copy link
Contributor

This pull request adds a more robust validation to the ResultPath.fromList method. As you can pass any object to GraphqlErrorException.Builder.path, it can lead to a ClassCastException when casting directly to int. this happened to me lol.

public T path(List<Object> path) {
  this.path = path;
  return (T)this.asDerivedType();
}

GraphqlErrorException.Builder.path

@@ -212,6 +212,13 @@ class ResultPathTest extends Specification {
path.toList() == ["a", "b"]
}

def "pass any other object than string or int"(){
when:
ResultPath.fromList(["a", "b", true])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the graphql-java code itself would never use anything but a String or Integer - but I am happy to have this be more robust

@bbakerman bbakerman merged commit 7e5987e into graphql-java:master Dec 4, 2024
1 check passed
@dondonz dondonz added this to the 23.x breaking changes milestone Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants