Skip to content

Terraform HTTP backend 404s when project-slug contains a period

Summary

terraform plan will fail with Error: Error locking state: Error acquiring the state lock: Unexpected HTTP response code 404 if your project slug contains a period .

Steps to reproduce

Follow verbatim the steps described in https://docs.gitlab.com/ee/user/infrastructure/ with a project containing a period . in the URL.

curl --header "private-token: {API-TOKEN}" https://gitlab.com/api/v4/projects/19062223/terraform/state/terraform-13.0-demo

returns {"message":"404 Not found"}

whereas a project without a period in the name, e.g.

curl --header "private-token: {API-TOKEN}" https://gitlab.com/api/v4/projects/19064746/terraform/state/terraform-gke-demo

returns {"version":1} after a terraform init.

Example Project

https://gitlab.com/jrreid/terraform-13.0-demo

Relevant logs and/or screenshots

https://gitlab.com/jrreid/terraform-13.0-demo/-/jobs/572409137

Output of checks

This bug happens on GitLab.com

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

/cc @nicholasklick

Edited by Jamie Reid