badges/shields · error · NotFound
no commits found
Error message
no commits found
What it means
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.
Source
Thrown at services/github/github-last-commit.service.js:104
}
static defaultBadgeData = { label: 'last commit' }
async fetch({ user, repo, branch, path }) {
return this._requestJson({
url: `/repos/${user}/${repo}/commits`,
options: { searchParams: { sha: branch, path, per_page: 1 } },
schema,
httpErrors: httpErrorsFor(),
})
}
async handle({ user, repo, branch }, queryParams) {
const { path, display_timestamp: displayTimestamp } = queryParams
const body = await this.fetch({ user, repo, branch, path })
const [commit] = body.map(obj => obj.commit)
if (!commit) throw new NotFound({ prettyMessage: 'no commits found' })
return renderDateBadge(commit[displayTimestamp].date)
}
}
View on GitHub (pinned to 766fd8bc89)
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)
Example fix
// before /badge/last-commit/user/repo/empty-branch?path=nonexistent-dir -> no commits found // after /badge/last-commit/user/repo/main
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure branch exists and has commits
const res = await fetch(`https://api.github.com/repos/${user}/${repo}/branches/${branch}`)
if (!res.ok) throw new Error(`branch ${branch} missing`)
const { commit } = await res.json() // commit.sha proves non-empty history Type guard
const hasCommit = (body) => Array.isArray(body) && body.length > 0 && Boolean(body[0]?.commit)
Try / catch
try {
await fetchLastCommitBadge(user, repo, branch, path)
} catch (e) {
if (e.message === 'no commits found') return 'unknown'
throw e
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- no commits found
- no commits found
- unknown type, provider, or upstream issue
- gist not found
- no matching releases found
AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30).
Data as JSON: /api/errors/f9ad573ca57ee127.
Report an issue: GitHub.