Group-level variables API returns 404
Summary
groups/:id/variables
returns a 404. This should return the variables as described here.
Steps to reproduce
In my local installation:
curl -k --header "PRIVATE-TOKEN: XXXXXXXXXXXX" https://gitlab.example.com/api/v4/groups/:id/variables
The token being used has all privileges and assigned to the owner of the group (root/administrator).
What is the current bug behavior?
API returns a 404
What is the expected correct behavior?
Should return a map of key/value pairs.
Relevant logs and/or screenshots
From the rails console of my local environment one can confirm that the group exists and has variables assigned:
Loading production environment (Rails 4.2.8)
irb(main):001:0> Group.find_by(id: 6)
=> #<Group id: 6, name: "test-group", path: "test-group", owner_id: nil, created_at: "2017-08-16 01:14:10", updated_at: "2017-08-16 01:14:10", type: "Group", description: "", avatar: nil, membership_lock: false, share_with_group_lock: false, visibility_level: 0, request_access_enabled: false, ldap_sync_status: "ready", ldap_sync_error: nil, ldap_sync_last_update_at: nil, ldap_sync_last_successful_update_at: nil, ldap_sync_last_sync_at: nil, deleted_at: nil, description_html: "", lfs_enabled: nil, parent_id: nil, shared_runners_minutes_limit: nil, repository_size_limit: nil, require_two_factor_authentication: false, two_factor_grace_period: 48, cached_markdown_version: 1, plan: nil>
irb(main):002:0> Group.find_by(id: 6).variables
=> #<ActiveRecord::Associations::CollectionProxy [#<Ci::GroupVariable id: 1, key: "testvar", value: nil, encrypted_value: "QmbBwC0eAMwz9DJCKKjlDA==\n", encrypted_value_salt: "_bZZAIjNuK3QepLkTARLzgQ==\n", encrypted_value_iv: "GomKF1yj0ddCHCWHleT/Yg==\n", group_id: 6, protected: false, created_at: "2017-08-16 01:17:44", updated_at: "2017-08-16 01:17:44">]>
irb(main):003:0>
When using the API the groups
endpoint works correctly but variables
throws a 404:
$ curl -k --header "PRIVATE-TOKEN: XXXXXXXXXXXX" https://gitlab-ee-latest/api/v4/groups/6/
{"id":6,"name":"test-group","path":"test-group","description":"","visibility":"private","ldap_cn":null,"ldap_access":null,"lfs_enabled":true,"avatar_url":null,"web_url":"https://gitlab-ee-latest/groups/test-group","request_access_enabled":false,"full_name":"test-group","full_path":"test-group","parent_id":null,"projects":[],"shared_projects":[],"shared_runners_minutes_limit":null}
$ curl -k --header "PRIVATE-TOKEN: XXXXXXXXXXXXX" https://gitlab-ee-latest/api/v4/groups/6/variables
{"error":"404 Not Found"}
Results of GitLab environment info
Occurring on 9.4.4
Possible fixes
(If you can, link to the line of code that might be responsible for the problem)
Links
Customer reported this issue, I have successfully reproduced in my local environment.
Customer ticket: https://gitlab.zendesk.com/agent/tickets/81254 (internal only)