{"record":{"id":"f6f6455f6ecd6f21","repo":"gitbutlerapp/gitbutler","slug":"failed-to-fetch-project-status-error-text","errorCode":null,"errorMessage":"Failed to fetch project: {status} - {error_text}","messagePattern":"Failed to fetch project: (.+?) - (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-gitlab/src/client.rs","lineNumber":638,"sourceCode":"        struct GitLabApiPermissions {\n            #[serde(default)]\n            project_access: Option<GitLabApiAccess>,\n            #[serde(default)]\n            group_access: Option<GitLabApiAccess>,\n        }\n\n        #[derive(Deserialize)]\n        struct GitLabApiAccess {\n            access_level: i64,\n        }\n\n        let url = format!(\"{}/projects/{}\", self.base_url, project_id);\n        let response = self.client.get(&url).send().await?;\n\n        if !response.status().is_success() {\n            let status = response.status();\n            let error_text = response.text().await.unwrap_or_default();\n            bail!(\"Failed to fetch project: {status} - {error_text}\");\n        }\n\n        let project: GitLabApiProject = response.json().await?;\n\n        let access_level = project.permissions.and_then(|p| {\n            let project_level = p.project_access.map(|a| a.access_level);\n            let group_level = p.group_access.map(|a| a.access_level);\n            match (project_level, group_level) {\n                (Some(a), Some(b)) => Some(a.max(b)),\n                (Some(a), None) | (None, Some(a)) => Some(a),\n                (None, None) => None,\n            }\n        });\n\n        Ok(GitLabProject {\n            id: project.id,\n            path_with_namespace: project.path_with_namespace,\n            ssh_url_to_repo: project.ssh_url_to_repo,","sourceCodeStart":620,"sourceCodeEnd":656,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-gitlab/src/client.rs#L620-L656","documentation":"fetch_project_by_path performs GET {base_url}/projects/{id} (URL-encoded path) and bails on any non-2xx status, embedding the status and GitLab's error body. It backs both fetch_project and fetch_project_by_numeric_id, so a 404 means GitLab could not resolve the project id/path for the authenticated token.","triggerScenarios":"Project path with unencoded special characters (`/`, `.`, spaces) reaching GitLab incorrectly, project id or path not visible to the token (private project, 404), token expired/insufficient scope (401/403), typo in the project path, or project was renamed/archived/deleted.","commonSituations":"User configured a project URL but the token belongs to a different account; repo moved to another namespace after a company reorg; path contains dots (e.g. `group.io/repo`) that must be URL-encoded as %2F; hitting the wrong GitLab host (gitlab.com vs self-hosted).","solutions":["Check the embedded status: 404 means verify the project path/id and that the token's user is a member of the project.","URL-encode the full project path with URL-encoding of `/` as %2F before interpolating into the endpoint.","For 401/403 confirm the token has `read_api`/`api` scope and is not expired.","Confirm base_url points at the correct GitLab instance (gitlab.com vs self-managed).","Re-fetch the project after a rename; update stored project identifiers."],"exampleFix":"// before\nlet url = format!(\"{}/projects/{}\", self.base_url, project_path);\n// after\nlet encoded = urlencoding::encode(project_path); // group/repo -> group%2Frepo\nlet url = format!(\"{}/projects/{}\", self.base_url, encoded);","handlingStrategy":"validation","validationCode":"fn encode_project_path(path: &str) -> String {\n    assert!(!path.trim().is_empty(), \"project path must not be empty\");\n    urlencoding::encode(path).to_string() // group/repo -> group%2Frepo\n}","typeGuard":null,"tryCatchPattern":"match client.fetch_project_by_path(\"group/repo\").await {\n    Err(e) if e.to_string().contains(\"404\") => {\n        // verify membership/path or prompt user to re-select project\n    }\n    Err(e) if e.to_string().contains(\"401\") => {\n        // refresh or re-authenticate the token\n    }\n    Err(e) => return Err(e),\n    Ok(p) => println!(\"{}\", p.id),\n}","preventionTips":["URL-encode project paths (encode '/' as %2F) — especially paths containing dots","Keep the token's scopes (read_api/api) valid and not expired","Confirm base_url matches the instance the project lives on (gitlab.com vs self-hosted)","Refresh cached project identifiers after namespace moves or renames"],"tags":["gitlab","http-error","project-lookup","api"],"backgroundTag":"http-error-response","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}