Sorting timelogs by `CREATED_ASC` results in 500 internal server error
Summary
When using the GraphQL timelog API with a sort
value of CREATED_ASC
, an internal server error occurs.
Steps to reproduce
- Navigate to the GraphQL explorer
- Run the following query:
{
group(fullPath: "test") {
timelogs(sort: CREATED_ASC) {
nodes {
id
}
}
}
}
Note: the group must exist for the error to occur.
Example Project
The problem occurs in any project or group, encountered with GitLab 15.8.3-ee
What is the current bug behavior?
If the query is sorted with CREATED_ASC
or CREATED_DESC
, an internal server error occurs and no usable output is produced.
What is the expected correct behavior?
A list of timelogs is returned, sorted by the given sort value.
Relevant logs and/or screenshots
{"component": "gitlab","subcomponent":"production_json","level":"error","method":"POST","path":"/api/graphql","format":"*/*","controller":"GraphqlController","action":"execute","status":500,"time":"2023-01-26T17:50:16.505Z","params":[{"key":"query","value":"{\n project(fullPath: \"MASKED\") {\n timelogs(first: 10, sort: CREATED_DESC) {\n nodes {\n id\n spentAt\n issue {\n title\n }\n }\n }\n }\n}\n"},{"key":"variables","value":"[FILTERED]"},{"key":"graphql","value":{"query":"{\n project(fullPath: \"MASKED\") {\n timelogs(first: 10, sort: CREATED_DESC) {\n nodes {\n id\n spentAt\n issue {\n title\n }\n }\n }\n }\n}\n","variables":"[FILTERED]"}}],"correlation_id":"01GQQK78C9S8AAM9T81R85N0Q1","meta.caller_id":"GraphqlController#execute","meta.remote_ip":"MASKED","meta.feature_category":"not_owned","meta.user":"MASKED","meta.user_id":1,"meta.client_id":"user/1","graphql":[{"depth":5,"complexity":11,"used_fields":["Timelog.id","Timelog.spentAt","Issue.title","Timelog.issue","TimelogConnection.nodes","Project.timelogs","Query.project"],"used_deprecated_fields":[],"variables":"{\"path\"=>\"MASKED\", \"after\"=>nil}","operation_name":null}],"remote_ip":"MASKED","user_id":1,"username":"MASKED","ua":"MASKED","queue_duration_s":0.007955,"request_urgency":"low","target_duration_s":5,"redis_calls":5,"redis_allowed_cross_slot_calls":1,"redis_duration_s":0.0012649999999999998,"redis_read_bytes":261,"redis_write_bytes":1205,"redis_sessions_calls":4,"redis_sessions_allowed_cross_slot_calls":1,"redis_sessions_duration_s":0.001102,"redis_sessions_read_bytes":261,"redis_sessions_write_bytes":1151,"redis_shared_state_calls":1,"redis_shared_state_duration_s":0.000163,"redis_shared_state_write_bytes":54,"db_count":6,"db_write_count":0,"db_cached_count":0,"db_replica_count":0,"db_primary_count":6,"db_main_count":6,"db_main_replica_count":0,"db_replica_cached_count":0,"db_primary_cached_count":0,"db_main_cached_count":0,"db_main_replica_cached_count":0,"db_replica_wal_count":0,"db_primary_wal_count":0,"db_main_wal_count":0,"db_main_replica_wal_count":0,"db_replica_wal_cached_count":0,"db_primary_wal_cached_count":0,"db_main_wal_cached_count":0,"db_main_replica_wal_cached_count":0,"db_replica_duration_s":0.0,"db_primary_duration_s":0.007,"db_main_duration_s":0.007,"db_main_replica_duration_s":0.0,"cpu_s":0.037609,"mem_objects":16719,"mem_bytes":1501152,"mem_mallocs":5124,"mem_total_bytes":2169912,"pid":14699,"worker_id":"puma_0","rate_limiting_gates":[],"exception.class":"TypeError","exception.message":"no implicit conversion of Symbol into Integer","exception.backtrace":["app/graphql/resolvers/timelog_resolver.rb:147:in `[]'","app/graphql/resolvers/timelog_resolver.rb:147:in `apply_sorting'","app/graphql/resolvers/timelog_resolver.rb:53:in `resolve_with_lookahead'","app/graphql/resolvers/concerns/looks_ahead.rb:14:in `resolve'","lib/gitlab/graphql/present/field_extension.rb:18:in `resolve'","lib/gitlab/graphql/tracers/timer_tracer.rb:20:in `trace'","lib/gitlab/graphql/generic_tracing.rb:48: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:48: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:48: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:173:in `execute_query'","app/controllers/graphql_controller.rb:57:in `execute'","ee/lib/gitlab/ip_address_state.rb:10:in `with'","ee/app/controllers/ee/application_controller.rb:46:in `set_current_ip_address'","app/controllers/application_controller.rb:534:in `set_current_admin'","lib/gitlab/session.rb:11:in `with_session'","app/controllers/application_controller.rb:525:in `set_session_storage'","lib/gitlab/i18n.rb:107:in `with_locale'","lib/gitlab/i18n.rb:113:in `with_user_locale'","app/controllers/application_controller.rb:513:in `set_locale'","app/controllers/application_controller.rb:507: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/handle_malformed_strings.rb:21:in `call'","lib/gitlab/middleware/basic_health_check.rb:25:in `call'","lib/gitlab/middleware/handle_ip_spoof_attack_error.rb:25:in `call'","lib/gitlab/middleware/request_context.rb:21: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:37: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:77:in `call'","lib/gitlab/middleware/release_env.rb:13:in `call'"],"db_duration_s":0.00566,"view_duration_s":0.00031,"duration_s":0.03077}
Possible fixes
The bug was likely introduced in 04f76e64. The sorting enum doesn't list all the options specified in the documentation.