Skip to content

use_custom_template for project results in a 500 error after upgrading to 16.6.*

Bug Report

After upgrading GitLab from 16.5.0 to 16.6.1, our terraform automation for generating new projects from a project template is broken, it now throws a 500 error. Upon researching the 500 error in GitLab's application logs, we find this attached to the correlation ID for the 500 error:

"message":"Unable to save project. Error: unknown attribute 'use_custom_template' for Project."

Relevant Terraform Configuration

resource "gitlab_project" "redacted-project" {
  for_each = var.clusters

  name         = each.key
  description  = "redacted repository for ${each.key}"
  namespace_id = local.targetGitlabGroupIds[var.environment]

  use_custom_template             = each.value["useProjectTemplate"]
  template_project_id             = each.value["useProjectTemplate"] ? data.gitlab_project.redacted-project-template.id : null
  group_with_project_templates_id = each.value["useProjectTemplate"] ? data.gitlab_group.project-templates.id : null

  merge_pipelines_enabled = true
}

Relevant Terraform Command

gitlab-terraform apply

Relevant Log Output

These are the debug logs of the `terraform` command output:
$ gitlab-terraform apply
Initializing the backend...
Successfully configured the backend "http"! Terraform will automatically
use this backend unless the backend configuration changes.
Initializing modules...
Initializing provider plugins...
- Reusing previous version of gitlabhq/gitlab from the dependency lock file
- Using previously-installed gitlabhq/gitlab v16.6.0
Terraform has been successfully initialized!
module.test.gitlab_project.REDACTED-project["REDACTED-preprod"]: Creating...
module.test.gitlab_project.REDACTED-project["REDACTED-preprod"]: Still creating... [10s elapsed]

│ Error: POST https://gitlab.REDACTED.com/api/v4/projects: 500 {message: 500 Internal Server Error}

│   with module.test.gitlab_project.REDACTED-project["REDACTED-preprod"],
│   on modules/redacted/redacted.tf line 1, in resource "gitlab_project" "REDACTED-project":
│    1: resource "gitlab_project" "REDACTED-project" {


Cleaning up project directory and file based variables
00:01
ERROR: Job failed: command terminated with exit code 1

Additional Details

  • GitLab Terraform Provider Version: 16.6.0
  • GitLab Version: 16.6.1
  • Terraform Version: ``
Edited by Michael G. Gerhart