GraphQL ignored-error-types should not rely only on ErrorClassification.toString()
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 52/100
Piste de recherche
Commencez dans SentryGraphqlInstrumentation et examinez comment error.getErrorType().toString() est comparé à ignored-error-types. Lisez le comportement de ErrorClassification.toSpecification(...) de graphql-java, puis définissez l’approche de matching afin que ExtendedValidationError puisse être ignorée sans remplacer l’interpolateur de messages ni dépendre de toString().
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Problem Statement
I am using the GraphQL integration with:
io.sentry:sentry-spring-boot-4io.sentry:sentry-graphql-22- Sentry Java SDK
8.42.0 com.graphql-java:graphql-java-extended-validation:24.0
I want to ignore expected GraphQL validation errors produced by graphql-java-extended-validation.
The configuration looks like this:
sentry.graphql.ignored-error-types:
- BAD_REQUEST
- UNAUTHORIZED
- FORBIDDEN
- NOT_FOUND
- ExtendedValidationError
This works well for enum-like ErrorClassification values, but it does not work reliably for errors from graphql-java-extended-validation.
From what I can see, SentryGraphqlInstrumentation currently resolves the error type with:
error.getErrorType().toString()
and then compares that string with ignoredErrorTypes.
The problem is that graphql-java-extended-validation uses a private ResourceBundleMessageInterpolator.ValidationErrorType class. It does not expose a stable enum-like value via toString(). The semantic classification is exposed through ErrorClassification.toSpecification(...), which returns a map like:
{
"type": "ExtendedValidationError",
"validatedPath": [...],
"constraint": "@..."
}
Because of this, I currently have to work around the issue by replacing the extended-validation MessageInterpolator and returning a custom ErrorClassification whose toString() returns ExtendedValidationError only when called from Sentry:
override fun toString(): String {
if (stackWalker.callerClass == SentryGraphqlInstrumentation::class.java) {
return "ExtendedValidationError"
}
return super.toString()
}
That workaround is brittle and depends on Sentry internals.
This looks related to #2899, which added easier GraphQL error filtering. The current string-based filtering solves enum-like classifications, but it is hard to use with custom ErrorClassification implementations where toSpecification(...) carries the meaningful classification.
Solution Brainstorm
Could Sentry support a more robust way to classify ignored GraphQL errors?
A few possible approaches:
-
When
error.getErrorType()is present, callerrorType.toSpecification(error)and, if it returns a map containing atypefield, allowignored-error-typesto match that value. -
Add a callback/predicate for GraphQL errors. This would allow applications to inspect GraphQLError, ErrorClassification, extensions, path, etc.
-
Pass the GraphQLError and/or ErrorClassification through the Sentry Hint, as mentioned in #2899, so users can filter these events in beforeSend without replacing the whole GraphQL instrumentation.
My preference would be option 1 for configuration compatibility, possibly combined with option 3 for advanced filtering.
This would also make the Sentry GraphQL integration work out of the box with graphql-java-extended-validation, which is an official companion library from the graphql-java project. Since Sentry Java already integrates with graphql-java, it would be helpful if expected validation errors from this commonly used library could be ignored without replacing the message interpolator or depending on ErrorClassification.toString().
- Langage dominant
- Kotlin
- Étoiles
- 1.4k
- Forks
- 479
- Merge moyen
- 2 j 17 h
- PR mergées (30 j)
- 68
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de getsentry/sentry-java
-
Platform: Java
Difficulté 2/5 Une demi-journée Accessibilité débutants 76/100
getsentry/sentry-java#6161 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Bug Java Platform: Android Platform: Java
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
getsentry/sentry-java#6138 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Feature Java Platform: Java Spans
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
getsentry/sentry-java#5984 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Android Task Traces
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
getsentry/sentry-java#5376 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Android Docs Errors
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
getsentry/sentry-java#5375 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de getsentry/sentry-java
Issues similaires
-
feat: 工作区文件菜单增加「复制文件路径」选项Ouverteenhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
good first issue help wanted
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
bug 🐞 Untriaged user issue
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
valkey-io/valkey-glide#7306 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
Bookmarking an article that is already bookmarked under its redirect URL deletes both bookmarksPeut-être pris @aakarshitv l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
kiwix/kiwix-android#5176 ·
Les mainteneurs répondent en général sous 1 jour
-
bug good first issue
Difficulté 1/5 1-3 heures Accessibilité débutants 77/100
open-telemetry/opentelemetry-kotlin#1202 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour