Database schema mismatch on web_hooks causing 500 error on Add project hook API endpoint
Summary
Attempting to use Add project hook API endpoint when specifying only required attributes results in 500 error which logs show as ActiveRecord::NotNullViolation
. Works fine on a different GitLab instance.
Steps to reproduce
- Have a GitLab version that has done a lot of upgrades over the years
- Try to create project hook using API endpoint and only
id
andurl
attributes
Example Project
Not possible
What is the current bug behavior?
500 error
What is the expected correct behavior?
No 500 error
Relevant logs and/or screenshots
==> /var/log/gitlab/postgresql/current <==
2019-08-01_22:43:40.64618 ERROR: null value in column "push_events" violates not-null constraint
2019-08-01_22:43:40.64622 DETAIL: Failing row contains (2953, 19678, 2019-08-01 22:43:40.64372+00, 2019-08-01 22:43:40.64372+00, ProjectHook, null, null, t, null, null, f, t, f, f, f, f, f, null, null, null, null, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
2019-08-01_22:43:40.64622 , xxxxxxxxxxxxxx
2019-08-01_22:43:40.64623 ).
2019-08-01_22:43:40.64623 STATEMENT: INSERT INTO "web_hooks" ("project_id", "created_at", "updated_at", "issues_events", "encrypted_url", "encrypted_url_iv") VALUES (19678, '2019-08-01 22:43:40.643720', '2019-08-01 22:43:40.643720', 't', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
2019-08-01_22:43:40.64624 ', 'xxxxxxxxxxxxxx
2019-08-01_22:43:40.64625 ') RETURNING "id"
ActiveRecord::NotNullViolation (PG::NotNullViolation: ERROR: null value in column "push_events" violates not-null constraint
DETAIL: Failing row contains (2953, 19678, 2019-08-01 22:43:40.64372+00, 2019-08-01 22:43:40.64372+00, ProjectHook, null, null, t, null, null, f, t, f, f, f, f, f, null, null, null, null, xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
, xxxxxxxxxxxxxx
).
: INSERT INTO "web_hooks" ("project_id", "created_at", "updated_at", "issues_events", "encrypted_url", "encrypted_url_iv") VALUES (19678, '2019-08-01 22:43:40.643720', '2019-08-01 22:43:40.643720', 't', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=
', 'xxxxxxxxxxxxxx
') RETURNING "id"):
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Current User: git Using RVM: no Ruby Version: 2.5.3p105 Gem Version: 2.7.9 Bundler Version:1.17.3 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.21.0 Sidekiq Version:5.2.7 Go Version: unknown
GitLab information Version: 11.11.5 Revision: b85e6215a85 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 9.6.11 URL: https://xxxxxxx.com HTTP Clone URL: https://xxxxxxx.com/some-group/some-project.git SSH Clone URL: git@xxxxxxx.com:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: saml
GitLab Shell Version: 9.1.0 Repository storage paths:
- default: /app/gitlab/git-data/repositories
GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
all passing
Possible fixes
Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/51438