Skip to content

API requests to /projects/:id using Group Access Token are missing the default_branch field

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

In Gitlab 16.7.5-ee, using a Group Access Token, API requests to /projects/:id are missing the default_branch in the response.

This is breaking Mend Renovate because it requires this field to exist.

Steps to reproduce

  1. Create empty repo in a group, e.g. https://gitlab.example.com/foo/bar
  2. Generate group access token under the foo group (developer role, scopes: read_api)
  3. Make API request with curl. Observe that the field does not exist.
➜  ~ curl -H 'PRIVATE-TOKEN: <group-access-token>' 'https://gitlab.example.com/api/v4/projects/foo%2Fbar' | jq '.default_branch'
null

Example Project

I am unable to accurately reproduce this on Gitlab.com because Group Access Tokens are disabled on free accounts.

It works as expected on Gitlab.com when I use a Personal Access Token, FWIW.

What is the current bug behavior?

default_branch is missing from the JSON response

What is the expected correct behavior?

default_branch will be included per the Projects API spec (https://docs.gitlab.com/ee/api/projects.html#get-single-project)

Results of GitLab environment info

  • I can reproduce this on self-hosted Gitlab 16.7.5-ee
  • It works correctly on self-hosted Gitlab 15.9.8 CE

Possible fixes

This also seems to work correctly if I create a Group Access Token with the "Maintainer" role

Edited by 🤖 GitLab Bot 🤖