GraphQL UnresolvedValueError: `DiffPosition.positionType` returned `"file"`, but this isn't a valid value for `DiffPositionType`.
Summary
Using PyCharm's Gitlab integration to retrieve the "timeline" view (via graphql) using PyCharm's Gitlab integration causes Gitlab to return a 500 error; the Gitlab log shows:
Types::Notes::PositionTypeEnum::UnresolvedValueError (`DiffPosition.positionType` returned `"file"` at `project.mergeRequest.discussions.nodes.13.notes.nodes.0.position.positionType`, but this isn't a valid value for `DiffPositionType`. Update the field or resolver to return one of `DiffPositionType`'s values instead.):
Gitlab::Diff::Position.position_type can take value "image", "text", or "file". (https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/diff/position.rb#L192 .) If the value is "file", it causes a GraphQL query to fail, because GraphQL's DiffPosition.positionType
can only be "image" or "text". (https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/graphql/types/notes/position_type_enum.rb)
Steps to reproduce
- Add a ZIP file to a branch and create an MR.
- Comment on the ZIP file.
- Load that MR using PyCharm's Gitlab integration.
- Pycharm shows an endless spinning progress wheel; Gitlab logs a 500 error.
Example Project
https://gitlab.com/c3pmark/graphql-diff-position
Run this in graphiql (https://gitlab.com/-/graphql-explorer):
{
project(fullPath: "c3pmark/graphql-diff-position") {
mergeRequest(iid: "1") {
discussions {
nodes {
notes(first: 1000) {
nodes {
position {
diffRefs {
baseSha
headSha
startSha
}
filePath
positionType
oldLine
oldPath
newLine
newPath
}
url
resolvable
resolved
userPermissions {
resolveNote
adminNote
}
}
}
}
}
}
}
}
What is the current bug behavior?
Gitlab returns a 500 and logs this exception:
Types::Notes::PositionTypeEnum::UnresolvedValueError (`DiffPosition.positionType` returned `"file"` at `project.mergeRequest.discussions.nodes.13.notes.nodes.0.position.positionType`, but this isn't a valid value for `DiffPositionType`. Update the field or resolver to return one of `DiffPositionType`'s values instead.):
What is the expected correct behavior?
Gitlab performs the GraphQL query and returns the requested data.
Relevant logs and/or screenshots
==> /var/log/gitlab/gitlab-rails/production.log <==
Types::Notes::PositionTypeEnum::UnresolvedValueError (`DiffPosition.positionType` returned `"file"` at `project.mergeRequest.discussions.nodes.13.notes.nodes.0.position.positionType`, but this isn't a valid value for `DiffPositionType`. Update the field or resolver to return one of `DiffPositionType`'s values instead.):
lib/gitlab/graphql/tracers/timer_tracer.rb:20:in `trace'
lib/gitlab/graphql/generic_tracing.rb:52:in `with_labkit_tracing'
lib/gitlab/graphql/generic_tracing.rb:38:in `platform_trace'
lib/gitlab/graphql/tracers/logger_tracer.rb:14:in `trace'
lib/gitlab/graphql/tracers/metrics_tracer.rb:13:in `trace'
lib/gitlab/graphql/tracers/application_context_tracer.rb:23:in `trace'
lib/gitlab/graphql/tracers/timer_tracer.rb:20:in `trace'
lib/gitlab/graphql/generic_tracing.rb:52:in `with_labkit_tracing'
lib/gitlab/graphql/generic_tracing.rb:38:in `platform_trace'
lib/gitlab/graphql/tracers/logger_tracer.rb:14:in `trace'
lib/gitlab/graphql/tracers/metrics_tracer.rb:13:in `trace'
lib/gitlab/graphql/tracers/application_context_tracer.rb:23:in `trace'
app/graphql/gitlab_schema.rb:51:in `multiplex'
app/controllers/graphql_controller.rb:199:in `execute_query'
app/controllers/graphql_controller.rb:64:in `execute'
app/controllers/concerns/sessionless_authentication.rb:41:in `sessionless_bypass_admin_mode!'
ee/lib/gitlab/ip_address_state.rb:10:in `with'
ee/app/controllers/ee/application_controller.rb:45:in `set_current_ip_address'
app/controllers/application_controller.rb:500:in `set_current_admin'
lib/gitlab/i18n.rb:107:in `with_locale'
app/controllers/application_controller.rb:484:in `set_locale'
app/controllers/application_controller.rb:475:in `set_current_context'
lib/gitlab/metrics/elasticsearch_rack_middleware.rb:16:in `call'
lib/gitlab/middleware/memory_report.rb:13:in `call'
lib/gitlab/middleware/speedscope.rb:13:in `call'
lib/gitlab/database/load_balancing/rack_middleware.rb:23:in `call'
lib/gitlab/middleware/rails_queue_duration.rb:33:in `call'
lib/gitlab/metrics/rack_middleware.rb:16:in `block in call'
lib/gitlab/metrics/web_transaction.rb:46:in `run'
lib/gitlab/metrics/rack_middleware.rb:16:in `call'
lib/gitlab/jira/middleware.rb:19:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:21:in `call'
lib/gitlab/middleware/query_analyzer.rb:11:in `block in call'
lib/gitlab/database/query_analyzer.rb:37:in `within'
lib/gitlab/middleware/query_analyzer.rb:11:in `call'
lib/gitlab/middleware/multipart.rb:173:in `call'
lib/gitlab/middleware/read_only/controller.rb:50:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/same_site_cookies.rb:27:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/middleware/handle_malformed_strings.rb:21:in `call'
lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'
lib/gitlab/middleware/request_context.rb:15:in `call'
lib/gitlab/middleware/webhook_recursion_detection.rb:15:in `call'
config/initializers/fix_local_cache_middleware.rb:11:in `call'
lib/gitlab/middleware/compressed_json.rb:44:in `call'
lib/gitlab/middleware/rack_multipart_tempfile_factory.rb:19:in `call'
lib/gitlab/middleware/sidekiq_web_static.rb:20:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:79:in `call'
lib/gitlab/middleware/release_env.rb:13:in `call'
Pycharm log:
2023-08-01 15:20:14,036 [ 22260] SEVERE - #o.j.p.g.m.d.GitLabMergeRequestDiscussionsContainer - HTTP Request Request POST https://gitlab/api/graphql/ failed with status code 500 and response body: {"errors":[{"message":"Internal server error"}]}
com.intellij.collaboration.api.HttpStatusErrorException: HTTP Request Request POST https://gitlab/api/graphql/ failed with status code 500 and response body: {"errors":[{"message":"Internal server error"}]}
at com.intellij.collaboration.api.httpclient.HttpClientUtil.checkStatusCodeWithLogging(HttpClientUtil.kt:45)
at com.intellij.collaboration.api.httpclient.HttpClientUtil.readSuccessResponseWithLogging(HttpClientUtil.kt:73)
at com.intellij.collaboration.api.graphql.GraphQLApiHelperImpl$loadResponseByClass$handler$1.invoke(GraphQLApiHelper.kt:65)
at com.intellij.collaboration.api.graphql.GraphQLApiHelperImpl$loadResponseByClass$handler$1.invoke(GraphQLApiHelper.kt:64)
at com.intellij.collaboration.api.httpclient.InflatedStreamReadingBodyHandler$apply$1.invoke(HttpClientUtil.kt:124)
at com.intellij.collaboration.api.httpclient.InflatedStreamReadingBodyHandler$apply$1.invoke(HttpClientUtil.kt:123)
at com.intellij.collaboration.api.httpclient.InflatedStreamReadingBodyHandler.apply$lambda$1(HttpClientUtil.kt:123)
at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:684)
at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:662)
at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2168)
at java.base/java.util.concurrent.CompletableFuture$MinimalStage.thenApply(CompletableFuture.java:2902)
at java.net.http/jdk.internal.net.http.ResponseSubscribers$MappingSubscriber.getBody(ResponseSubscribers.java:821)
at com.intellij.collaboration.api.httpclient.response.CancellableWrappingBodyHandler$SubscriberWrapper.getBody(CancellableWrappingBodyHandler.kt)
at java.net.http/jdk.internal.net.http.ResponseSubscribers.lambda$getBodyAsync$3(ResponseSubscribers.java:1153)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:702)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:699)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:699)
at java.base/java.lang.Thread.run(Thread.java:833)
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 3.0.6p216 Gem Version: 3.4.13 Bundler Version:2.4.14 Rake Version: 13.0.6 Redis Version: 6.2.11 Sidekiq Version:6.5.7 Go Version: unknown GitLab information Version: 16.1.2-ee Revision: 0642e8c5c91 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 13.11 URL: https://gitlab HTTP Clone URL: https://gitlab/some-group/some-project.git SSH Clone URL: git@gitlab:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 14.23.0 Repository storages: - default: unix:/var/opt/gitlab/gitaly/gitaly.socket GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 14.23.0 ? ... OK (14.23.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... Server: ldapmain LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 100 users of 100 limit.
Checking LDAP ... Finished
Checking GitLab App ...
Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Cable config exists? ... yes Resque config exists? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Systemd unit files or init script exist? ... skipped (omnibus-gitlab has neither init script nor systemd units) Systemd unit files or init script up-to-date? ... skipped (omnibus-gitlab has neither init script nor systemd units) Projects have namespace: ... 2/1 ... yes 7/4 ... yes 7/6 ... yes 7/7 ... yes 7/8 ... yes 14/9 ... yes 20/10 ... yes 37/11 ... yes 20/12 ... yes 17/13 ... yes 25/14 ... yes 25/15 ... yes 25/16 ... yes 25/17 ... yes 25/18 ... yes 25/20 ... yes 7/21 ... yes 7/22 ... yes 7/23 ... yes 53/24 ... yes 20/25 ... yes 7/26 ... yes 14/29 ... yes 16/30 ... yes 20/31 ... yes 7/32 ... yes 22/33 ... yes 7/34 ... yes 20/36 ... yes 65/37 ... yes 20/38 ... yes 20/40 ... yes 14/41 ... yes 7/42 ... yes 22/43 ... yes 7/44 ... yes 20/45 ... yes 14/46 ... yes 14/47 ... yes 86/50 ... yes 86/51 ... yes 86/52 ... yes 86/54 ... yes 86/55 ... yes 7/57 ... yes 7/58 ... yes 20/60 ... yes 7/61 ... yes 20/62 ... yes 86/63 ... yes 86/64 ... yes 86/65 ... yes 86/66 ... yes 86/67 ... yes 14/69 ... yes 14/70 ... yes 86/71 ... yes 86/72 ... yes 86/73 ... yes 128/78 ... yes 20/79 ... yes 7/80 ... yes 86/81 ... yes 20/82 ... yes 20/83 ... yes 20/84 ... yes 7/85 ... yes 7/86 ... yes 7/87 ... yes 7/89 ... yes 7/90 ... yes 153/91 ... yes 153/92 ... yes 7/93 ... yes 86/94 ... yes 7/95 ... yes 7/96 ... yes 7/97 ... yes 4/98 ... yes 7/99 ... yes 7/100 ... yes 4/101 ... yes 25/102 ... yes 25/103 ... yes Redis version >= 6.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (3.0.6) Git user has default SSH configuration? ... yes Active users: ... 27 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x-8.x or OpenSearch version 1.x ... skipped (Advanced Search is disabled) All migrations must be finished before doing a major upgrade ... skipped (Advanced Search is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
Add file
to the PositionTypeEnum
?
https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/graphql/types/notes/position_type_enum.rb#L5