[500] Empty project index or 500 error on project view: `missing required keys: [:id]):`
Created by: karlnp
Summary: When clicking on GROUP/PROJECT from the index, the project's commit history fails to render. When clicking on the issue history tab from the project's index, Gitlab returns a 500 error.
Steps to reproduce: Modify a project's "issues_tracker" VARCHAR column in gitlabhq_production database to any non-"gitlab" value. Visit project index. Witness failure to render or 500 error.
Tested on 6.9.2, 7.0.0, and 7.2.1 of github-omnibus.
Expected behaviour: The project's commit history renders properly.
Observed behaviour: The project's commit history fails to render and the "Issues" tab results in a 500 error.
Relevant logs:
Started GET "/hq/api?limit=20&offset=0" for 127.0.0.1 at 2014-09-02 13:42:05 -0700
Processing by ProjectsController#show as JSON
Parameters: {"limit"=>"20", "offset"=>"0", "id"=>"hq/api"}
Read fragment views/events/662-20140829180652031921000/6addc44650dc1f7c66594c3371b56320 (0.3ms)
Read fragment views/events/651-20140828235331096222000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/650-20140828235331011859000/6addc44650dc1f7c66594c3371b56320 (0.2ms)
Read fragment views/events/649-20140828235327455417000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/648-20140828235251484614000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/645-20140828185311823304000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/640-20140827191558168772000/6addc44650dc1f7c66594c3371b56320 (0.2ms)
Read fragment views/events/639-20140827191558133501000/6addc44650dc1f7c66594c3371b56320 (0.2ms)
Read fragment views/events/638-20140827185244804145000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/637-20140827182815276511000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/593-20140821180933863703000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/563-20140819203329140149000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/562-20140819194215990047000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/559-20140818174924138608000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Read fragment views/events/558-20140818173447542021000/6addc44650dc1f7c66594c3371b56320 (0.1ms)
Completed 500 Internal Server Error in 60ms
ActionView::Template::Error (No route matches {:action=>"show", :controller=>"projects/issues", :id=>"SEC-12", :project_id=>#<Project id: 33, name: "API", path: "api", description: "", created_at: "2014-07-15 23:06:04", updated_at: "2014-08-28 23:53:31", creator_id: 10, issues_enabled: true, wall_enabled: false, merge_requests_enabled: true, wiki_enabled: true, namespace_id: 15, issues_tracker: "jira", issues_tracker_id: "HQ", snippets_enabled: false, last_activity_at: "2014-08-29 18:06:52", import_url: "", visibility_level: 10, archived: false, import_status: "none", repository_size: 27.48, star_count: 0>} missing required keys: [:id]):
2: .commit-row-title
3: = link_to commit[:id][0..8], project_commit_path(project, commit[:id]), class: "commit_short_id", alt: ''
4:
5: = gfm event_commit_title(commit[:message]), project
app/helpers/issues_helper.rb:45:in `url_for_issue'
lib/gitlab/markdown.rb:186:in `reference_issue'
lib/gitlab/markdown.rb:168:in `reference_link'
lib/gitlab/markdown.rb:128:in `block in parse_references'
lib/gitlab/markdown.rb:117:in `gsub!'
lib/gitlab/markdown.rb:117:in `parse_references'
lib/gitlab/markdown.rb:93:in `parse'
lib/gitlab/markdown.rb:58:in `gfm'
app/views/events/_commit.html.haml:5:in `_app_views_events__commit_html_haml___4578344336854517507_33405420'
app/views/events/event/_push.html.haml:18:in `block in _app_views_events_event__push_html_haml___715571541375820747_33764440'
app/views/events/event/_push.html.haml:17:in `each'
app/views/events/event/_push.html.haml:17:in `_app_views_events_event__push_html_haml___715571541375820747_33764440'
app/views/events/_event.html.haml:10:in `block in _app_views_events__event_html_haml___4235081977598864450_21729400'
app/views/events/_event.html.haml:6:in `_app_views_events__event_html_haml___4235081977598864450_21729400'
app/views/events/_events.html.haml:1:in `_app_views_events__events_html_haml___368340562035649809_23159720'
app/controllers/application_controller.rb:223:in `pager_json'
app/controllers/projects_controller.rb:74:in `block (2 levels) in show'
app/controllers/projects_controller.rb:65:in `show'
Output of checks:
Gitlab-omnibus 6.9.2
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
System information
System: Ubuntu 14.04
Current User: git
Using RVM: no
Ruby Version: 2.0.0p451
Gem Version: 2.2.1
Bundler Version:1.5.3
Rake Version: 10.3.1
Sidekiq Version:2.17.0
GitLab information
Version: 6.9.2
Revision: e46b644
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: https://gitlab.mycorporation.com
HTTP Clone URL: https://gitlab.mycorporation.com/some-project.git
SSH Clone URL: [email protected]:some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 1.9.4
Repositories: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git: /opt/gitlab/embedded/bin/git
/var/opt/gitlab$ sudo gitlab-rake gitlab:check RAILS_ENV=production SANITIZE=true
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
Checking Environment ...
Git configured for git user? ... yes
Checking Environment ... Finished
Checking GitLab Shell ...
GitLab Shell version >= 1.9.4 ? ... OK (1.9.4)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
Satellites access is drwxr-x---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ...
######## deleted project names - all update hooks are links
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files:
/var/opt/gitlab/git-data/repositories: OK
/var/opt/gitlab/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 2.8.2
Send ping to redis server: PONG
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
Database contains orphaned UsersGroups? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Init script exists? ... no
Try fixing it:
Install the init script
For more information see:
doc/install/installation.md in section "Install Init Script"
Please fix the error above and rerun the checks.
Init script up-to-date? ... can't check because of previous errors
projects have namespace: ...
######## deleted project names - all projects have namespace
Projects have satellites? ...
######## deleted project names - all projects have satellites
Redis version >= 2.0.0? ... yes
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 1.7.10 ? ... yes (1.8.5)
Checking GitLab ... Finished
Gitlab-omnibus 7.2.1
/var/opt/gitlab$ sudo gitlab-rake gitlab:env:info
System information
System: Ubuntu 14.04
Current User: git
Using RVM: no
Ruby Version: 2.1.2p95
Gem Version: 2.2.1
Bundler Version:1.5.3
Rake Version: 10.3.2
Sidekiq Version:2.17.0
GitLab information
Version: 7.2.1
Revision: ff1633f
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresqlå
URL: https://gitlab.mycorporation.com
HTTP Clone URL: https://gitlab.mycorporation.com/some-project.git
SSH Clone URL: [email protected]:some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 1.9.7
Repositories: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks/
Git: /opt/gitlab/embedded/bin/git
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
Checking Environment ...
Git configured for git user? ... yes
Checking Environment ... Finished
Checking GitLab Shell ...
GitLab Shell version >= 1.9.7 ? ... OK (1.9.7)
Repo base directory exists? ... yes
Repo base directory is a symlink? ... no
Repo base owned by git:git? ... yes
Repo base access is drwxrws---? ... yes
Satellites access is drwxr-x---? ... yes
update hook up-to-date? ... yes
update hooks in repos are links: ...
######## deleted project names - all update hooks are links
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Check directories and files:
/var/opt/gitlab/git-data/repositories: OK
/var/opt/gitlab/.ssh/authorized_keys: OK
Test redis-cli executable: redis-cli 2.8.2
Send ping to redis server: PONG
gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Database config exists? ... yes
Database is SQLite ... no
All migrations up? ... yes
Database contains orphaned UsersGroups? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... 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: ...
######## deleted project names - all projects have namespace
Projects have satellites? ...
######## deleted project names - all projects have satellites
Redis version >= 2.0.0? ... yes
Ruby version >= 2.0.0 ? ... yes (2.1.2)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 1.7.10 ? ... yes (2.0.0)
Checking GitLab ... Finished
Steps to fix:
In gitlab-ctl dbconsole:
gitlabhq_production=> update projects set issues_tracker='gitlab' where issues_tracker != 'gitlab';
This is just a bandaid.. the issue appears to spring from this conditional: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/helpers/issues_helper.rb#L45
if project.used_default_issues_tracker? || !external_issues_tracker_enabled?
url = project_issue_url project_id: project, id: issue_iid
else
url = Gitlab.config.issues_tracker[project.issues_tracker]['issues_url']
url.gsub(':id', issue_iid.to_s).
gsub(':project_id', project.id.to_s).
gsub(':issues_tracker_id', project.issues_tracker_id.to_s)
end
Since issues in JIRA naturally don't have an equivalent issue in Gitlab, when the project was not created using JIRA but switched to JIRA after being created with the default tracker, this error is thrown.
Alternately, it could be that we use multiple JIRA projects for ticketing and they don't match the group Id field, but that doesn't seem plausible - surely that's a common use-case for JIRA integration?
If the application behaved correctly, the issue_iid parameter would presumably correctly propagate. I'm not completely sure that this is the explanation, however; I'm just happy I found a way to fix it for now. Please let me know if this was the result of some misconfiguration... there is precious little documentation around this kind of thing. Thanks!