StatementInvalid error on filtering group issues
Summary
When filtering a group issue board using a search term, a HTTP error 500 - Whoops, something went wrong on our end. is displayed. As to the logs, the cause is a StatementInvalid
error.
Steps to reproduce
- Open a group issue list
- Sort by priority
- Enter a search term (just text, nothing special)
- Hit enter
I tried different ways to reproduce the bug. It doesn't matter if the search term does return results.
The main factor seems to be the sort order. Priority, Label priority and Popularity cause the error, the other sort orders work fine.
What is the current bug behavior?
An error page 500 - Whoops, something went wrong on our end. is shown.
What is the expected correct behavior?
The group issue list should be filtered correctly.
Relevant logs and/or screenshots
Relevant part of /var/log/gitlab/gitlab-rails/production.log
:
Started GET "/groups/my-group-id/-/issues?scope=all&search=test&sort=priority&state=opened&utf8=%E2%9C%93" for 127.0.0.1 at 2019-02-05 15:46:36 +0100
Processing by GroupsController#issues as HTML
Parameters: {"scope"=>"all", "search"=>"test", "sort"=>"priority", "state"=>"opened", "utf8"=>"✓", "id"=>"my-group-id"}
Completed 500 Internal Server Error in 31ms (ActiveRecord: 3.9ms | Elasticsearch: 0.0ms)
ActiveRecord::StatementInvalid (PG::GroupingError: ERROR: column "issues.title" must appear in the GROUP BY clause or be used in an aggregate function
LINE 3: ...pened')) AND "projects"."archived" = 'f') SELECT issues.*, ...
^
: WITH "issues" AS (SELECT "issues".* FROM "issues" INNER JOIN "projects" ON "projects"."id" = "issues"."project_id" LEFT JOIN project_features ON projects.id = project_features.project_id WHERE "projects"."namespace_id" IN (WITH RECURSIVE "base_and_descendants" AS (SELECT "namespaces".* FROM "namespaces" WHERE "name
spaces"."type" IN ('Group') AND "namespaces"."id" = 31
UNION
SELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."type" IN ('Group') AND "namespaces"."parent_id" = "base_and_descendants"."id") SELECT "id" FROM "base_and_descendants" AS "namespaces") AND (EXISTS (SELECT 1 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = 4 A
ND (project_authorizations.project_id = projects.id)) OR projects.visibility_level IN (0,10,20)) AND ("project_features"."issues_access_level" > 0 OR "project_features"."issues_access_level" IS NULL) AND ("issues"."state" IN ('opened')) AND "projects"."archived" = 'f') SELECT issues.*, (SELECT MIN("label_priorities"
."priority") FROM "labels" INNER JOIN "label_links" ON "label_links"."label_id" = "labels"."id" LEFT OUTER JOIN "label_priorities" ON "labels"."id" = "label_priorities"."label_id" WHERE (label_priorities.project_id = issues.project_id) AND (label_links.target_id = issues.id) AND "label_links"."target_type" = 'Issue')
AS highest_priority, MIN(milestones.due_date) FROM issues INNER JOIN "projects" ON "projects"."id" = "issues"."project_id" LEFT OUTER JOIN milestones ON issues.milestone_id = milestones.id WHERE ("issues"."title" ILIKE '%test%' OR "issues"."description" ILIKE '%test%') AND "projects"."archived" = 'f' GROUP BY "issue
s"."id" ORDER BY MIN(milestones.due_date) ASC NULLS LAST, highest_priority ASC NULLS LAST, "issues"."id" DESC LIMIT 20 OFFSET 0):
lib/gitlab/issuable_metadata.rb:18:in `issuable_meta_data'
app/controllers/concerns/issues_action.rb:14:in `issues'
lib/gitlab/i18n.rb:55:in `with_locale'
lib/gitlab/i18n.rb:61:in `with_user_locale'
app/controllers/application_controller.rb:417:in `set_locale'
lib/gitlab/middleware/multipart.rb:103:in `call'
lib/gitlab/request_profiler/middleware.rb:16:in `call'
ee/lib/gitlab/jira/middleware.rb:15:in `call'
lib/gitlab/middleware/go.rb:20:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/correlation_id.rb:16:in `block in call'
lib/gitlab/correlation_id.rb:15:in `use_id'
lib/gitlab/middleware/correlation_id.rb:15:in `call'
lib/gitlab/middleware/read_only/controller.rb:42:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/request_context.rb:20:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:29:in `call'
lib/gitlab/middleware/release_env.rb:13:in `call'
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 18.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.5.3p105 Gem Version: 2.7.6 Bundler Version:1.16.6 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.3 Go Version: unknownGitLab information Version: 11.7.4-ee Revision: 3a39cd4 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.11 URL: https://my-host HTTP Clone URL: https://my-host/some-group/some-project.git SSH Clone URL: git@my-host:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers:
GitLab Shell Version: 8.4.4 Repository storage paths:
- default: /data/git_repos/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
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 >= 8.4.4 ? ... OK (8.4.4) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: 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 ... 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 not verifying SSL hostname of LDAPS server 'my-ldap:636' LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) -- removed sensitive information --
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... 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 Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 31/1 ... yes 5/3 ... yes 6/4 ... yes 6/5 ... yes 6/6 ... yes 7/7 ... yes 7/8 ... yes 8/9 ... yes 8/10 ... yes 36/11 ... yes 5/12 ... yes 12/13 ... yes 13/14 ... yes 13/15 ... yes 13/16 ... yes 13/17 ... yes 13/18 ... yes 13/19 ... yes 5/20 ... yes 14/21 ... yes 36/22 ... yes 5/23 ... yes 34/24 ... yes 17/25 ... yes 5/26 ... yes 34/27 ... yes 5/28 ... yes 31/29 ... yes 22/30 ... yes 18/31 ... yes 31/32 ... yes 6/33 ... yes 36/34 ... yes 23/35 ... yes 20/36 ... yes 31/37 ... yes 17/38 ... yes 10/39 ... yes 6/40 ... yes 5/41 ... yes 31/43 ... yes 34/44 ... yes 34/45 ... yes 34/46 ... yes 34/47 ... yes 22/48 ... yes 22/49 ... yes 6/51 ... yes 34/52 ... yes 31/53 ... yes 6/54 ... yes 38/55 ... yes 12/56 ... yes 31/57 ... yes 34/58 ... yes 40/59 ... yes 36/60 ... yes 36/61 ... yes 31/63 ... yes 40/64 ... yes 40/65 ... yes 31/66 ... yes 31/67 ... yes 40/68 ... yes 40/69 ... yes 31/70 ... yes 42/71 ... yes 17/72 ... yes 31/74 ... yes 31/75 ... yes 31/76 ... yes 40/77 ... yes 45/78 ... yes 34/80 ... yes 34/81 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 17 Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished