{"record":{"id":"7f259445d6cb77bc","repo":"badges/shields","slug":"no-commits-found-7f2594","errorCode":null,"errorMessage":"no commits found","messagePattern":"no commits found","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"services/gitlab/gitlab-last-commit.service.js","lineNumber":87,"sourceCode":"    // https://docs.gitlab.com/ee/api/commits.html#list-repository-commits\n    return super.fetch({\n      url: `${baseUrl}/api/v4/projects/${encodeURIComponent(\n        project,\n      )}/repository/commits`,\n      options: { searchParams: { ref_name: ref, path, per_page: 1 } },\n      schema,\n      httpErrors: httpErrorsFor('project not found'),\n    })\n  }\n\n  async handle(\n    { project },\n    { gitlab_url: baseUrl = 'https://gitlab.com', ref, path },\n  ) {\n    const data = await this.fetch({ project, baseUrl, ref, path })\n    const [commit] = data\n\n    if (!commit) throw new NotFound({ prettyMessage: 'no commits found' })\n\n    return renderDateBadge(commit.committed_date)\n  }\n}\n","sourceCodeStart":69,"sourceCodeEnd":92,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/gitlab/gitlab-last-commit.service.js#L69-L92","documentation":"The GitLab last-commit service fetches the commit list for a project/ref and destructures the first element. When the API returns an empty array, `commit` is undefined and the service throws `NotFound` with 'no commits found'. The request succeeded; there is simply no commit data for the given project/ref/path combination.","triggerScenarios":"Fetching last-commit for an empty GitLab project; a `ref` matching no commits (unborn/empty branch); a `path` that has no commit history on that ref.","commonSituations":"Freshly created empty repository; badge pointing at a branch before its first commit; path filter referencing a non-existent directory/file; wrong ref name resolving to nothing.","solutions":["Verify the project path in the badge URL points at a non-empty repository","Check the `ref` parameter names an existing branch/tag with commits","Remove or fix the `path` parameter if it filters out all commits","Push at least one commit to the referenced branch"],"exampleFix":"// before\n/badge/last-commit/group/empty-project?ref=new-branch   -> no commits found\n// after\n/badge/last-commit/group/project?ref=main","handlingStrategy":"try-catch","validationCode":"const res = await fetch(`${baseUrl}/api/v4/projects/${encodeURIComponent(project)}/repository/commits?ref_name=${ref}`)\nconst commits = await res.json()\nif (Array.isArray(commits) && commits.length === 0) throw new Error(`no commits for ref '${ref}'`)","typeGuard":"const hasCommits = (data) => Array.isArray(data) && data.length > 0","tryCatchPattern":"try {\n  await fetchGitLabLastCommitBadge(project, ref, path)\n} catch (e) {\n  if (e.message === 'no commits found') return 'unknown'\n  throw e\n}","preventionTips":["Point the badge at a non-empty project and a ref that exists with commits","Only use `path` when that path has history on the ref","Verify empty repos/branches before adding last-commit badges"],"tags":["gitlab","not-found","git","empty-response"],"backgroundTag":"empty-response-no-data","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}