GraphQL ignored-error-types should not rely only on ErrorClassification.toString()
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
調査の方向性
SentryGraphqlInstrumentationから始めて、error.getErrorType().toString()がignored-error-typesとどのように比較されているかを調べます。graphql-javaのErrorClassification.toSpecification(...)の動作を読み、そのうえで、メッセージ補間器を置き換えたりtoString()に依存したりせずにExtendedValidationErrorを無視できるよう、マッチング方式を定義します。
索引モデルが issue の本文から書いたものです。
説明
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().
- 主要言語
- Kotlin
- スター
- 1.4k
- フォーク
- 478
- 平均マージ
- 2日 20時間
- マージ済み PR(30日)
- 71
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
getsentry/sentry-java のほかの issue
-
Improvement Java Platform: Android Platform: Java
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
getsentry/sentry-java#6145 · コメント 1 件 · 担当者 1 名 ·
-
Bug Java Platform: Android Platform: Java
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
getsentry/sentry-java#6138 · コメント 1 件 ·
-
Feature Java Platform: Java Spans
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-java#5984 · コメント 1 件 ·
-
Android Task Traces
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
getsentry/sentry-java#5376 · コメント 1 件 ·
-
Android Docs Errors
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
getsentry/sentry-java#5375 · コメント 1 件 ·
getsentry/sentry-java の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
libre-tube/LibreTube#8803 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
Telegram !!! オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Xposed-Modules-Repo/com.fuck.iab#24 · コメント 3 件 · リアクション 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
SimonHalvdansson/Harmonic-HN#361 ·