{"record":{"id":"f9ad573ca57ee127","repo":"badges/shields","slug":"no-commits-found-f9ad57","errorCode":null,"errorMessage":"no commits found","messagePattern":"no commits found","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"services/github/github-last-commit.service.js","lineNumber":104,"sourceCode":"  }\n\n  static defaultBadgeData = { label: 'last commit' }\n\n  async fetch({ user, repo, branch, path }) {\n    return this._requestJson({\n      url: `/repos/${user}/${repo}/commits`,\n      options: { searchParams: { sha: branch, path, per_page: 1 } },\n      schema,\n      httpErrors: httpErrorsFor(),\n    })\n  }\n\n  async handle({ user, repo, branch }, queryParams) {\n    const { path, display_timestamp: displayTimestamp } = queryParams\n    const body = await this.fetch({ user, repo, branch, path })\n    const [commit] = body.map(obj => obj.commit)\n\n    if (!commit) throw new NotFound({ prettyMessage: 'no commits found' })\n\n    return renderDateBadge(commit[displayTimestamp].date)\n  }\n}\n","sourceCodeStart":86,"sourceCodeEnd":109,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/github/github-last-commit.service.js#L86-L109","documentation":"The GitHub last-commit service fetches the commit list for a branch (optionally narrowed by `path`) and destructures the first commit. GitHub's API returns an empty array when nothing matches, so `commit` is undefined and the service throws `NotFound` with 'no commits found'. This indicates a valid request whose result set is empty, not a network/auth failure.","triggerScenarios":"Fetching last-commit for a branch that has no commits (empty repo / freshly created branch); using a `path` query param that matches no files in the branch's history; misspelled branch name resolving to an empty ref list.","commonSituations":"Empty or newly initialized repository; pointing the badge at a branch before the first push; a path filter (e.g. subfolder) that does not exist on that branch; typo in branch name.","solutions":["Verify the branch name in the badge URL exists on GitHub","Remove or correct the `path` query parameter so it matches real files","Push at least one commit to the branch","Point the badge at the default branch (e.g. main/master)"],"exampleFix":"// before\n/badge/last-commit/user/repo/empty-branch?path=nonexistent-dir   -> no commits found\n// after\n/badge/last-commit/user/repo/main","handlingStrategy":"try-catch","validationCode":"// ensure branch exists and has commits\nconst res = await fetch(`https://api.github.com/repos/${user}/${repo}/branches/${branch}`)\nif (!res.ok) throw new Error(`branch ${branch} missing`)\nconst { commit } = await res.json() // commit.sha proves non-empty history","typeGuard":"const hasCommit = (body) => Array.isArray(body) && body.length > 0 && Boolean(body[0]?.commit)","tryCatchPattern":"try {\n  await fetchLastCommitBadge(user, repo, branch, path)\n} catch (e) {\n  if (e.message === 'no commits found') return 'unknown'\n  throw e\n}","preventionTips":["Use an existing, pushed branch (usually the default branch)","Only pass `path` when the path exists on that branch","Never point the badge at an empty repository"],"tags":["github","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"}