gentics / gentics/mesh

Schema-Fieldname containing special chars causes graphql to fail

Open
#121 1 comment 0 reactions 0 assignees View on GitHub
bug minor stability
Dominant language
Java
Stars
593
Forks
123
Avg merge
2d 18h
Merged PRs (30d)
4

Description

## Gentics Mesh Version, operating system, or hardware.
- v0.9.27

## Problem
If a schema or microschema contains a character which is not alphanumeric (or '_') all queries to graphql fail. With the following exception
`````
15:03:53.951 [Dumbstruck Monferno] ERROR [vert.x-eventloop-thread-4] [FailureHandler.java:91] - Error for request in path: /api/v1/kofl/graphql/?null
15:03:53.952 [Dumbstruck Monferno] ERROR [vert.x-eventloop-thread-4] [FailureHandler.java:93] - Error:
graphql.AssertException: Name must be non-null, non-empty and match [_A-Za-z][_0-9A-Za-z]*
at graphql.Assert.assertValidName(Assert.java:35) ~[mesh-server-0.9.27.jar:na]
at graphql.schema.GraphQLFieldDefinition.(GraphQLFieldDefinition.java:35) ~[mesh-server-0.9.27.jar:na]
at graphql.schema.GraphQLFieldDefinition$Builder.build(GraphQLFieldDefinition.java:215) ~[mesh-server-0.9.27.jar:na]
at com.gentics.mesh.graphql.type.field.FieldDefinitionProvider.createStringDef(FieldDefinitionProvider.java:173) ~[mesh-server-0.9.27.jar:na]
at com.gentics.mesh.graphql.type.field.MicronodeFieldTypeProvider.generateMicroschemaFieldType(MicronodeFieldTypeProvider.java:86) ~[mesh-server-0.9.27.
jar:na]
at com.gentics.mesh.graphql.type.field.MicronodeFieldTypeProvider.createType(MicronodeFieldTypeProvider.java:49) ~[mesh-server-0.9.27.jar:na]
at com.gentics.mesh.graphql.type.QueryTypeProvider.getRootSchema(QueryTypeProvider.java:436) ~[mesh-server-0.9.27.jar:na]
at com.gentics.mesh.graphql.GraphQLHandler.handleQuery(GraphQLHandler.java:56) ~[mesh-server-0.9.27.jar:na]
at com.gentics.mesh.graphql.GraphQLEndpoint.lambda$registerEndPoints$0(GraphQLEndpoint.java:50) ~[mesh-server-0.9.27.jar:na]
at io.vertx.ext.web.impl.RouteImpl.handleContext(RouteImpl.java:217) [mesh-server-0.9.27.jar:na]
at io.v
`````
And the following http-response body
`````
{
"message" : "Name must be non-null, non-empty and match [_A-Za-z][_0-9A-Za-z]*"
}
`````

## Expected behaviour

It should not be possible to add schemas or microschemas containing fieldnames with special chars. Alternatively the error message returned to the user should be more descriptive (containing the schema and fieldname where the error occurs)

Contributor guide

Open the contributing guide

Research direction

Start with the GraphQL stack trace and inspect FieldDefinitionProvider.java, MicronodeFieldTypeProvider.java, QueryTypeProvider.java, and GraphQLHandler.java to trace where schema field names are turned into GraphQL fields. Determine whether invalid names are rejected during schema or microschema creation, or whether the GraphQL error can identify the schema and field. Done means invalid names no longer make GraphQL queries fail silently and the reported behavior is covered by the relevant verification.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, java
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.