badges/shields · error · NotFound

no commits found

Error message

no commits found

What it means

The Bitbucket last-commit service fetches the commit list for a repository/branch/path and destructures the first entry from data.values. If the list is empty (no commit found), handle throws NotFound 'no commits found', so the badge reports that the requested branch/path has no commits instead of crashing.

Source

Thrown at services/bitbucket/bitbucket-last-commit.service.js:69

          path,
          pagelen: 1,
          fields: 'values.date',
        },
      },
      schema,
      httpErrors: {
        403: 'private repo',
        404: 'user, repo or branch not found',
      },
    })
  }

  async handle({ user, repo, branch }, queryParams) {
    const { path } = queryParams
    const data = await this.fetch({ user, repo, branch, path })
    const [commit] = data.values

    if (!commit) throw new NotFound({ prettyMessage: 'no commits found' })

    return renderDateBadge(commit.date)
  }
}

View on GitHub (pinned to 766fd8bc89)

Solutions

  1. Verify the branch name in the badge URL against the repository's branches.
  2. Remove or correct the path query parameter if it filters out all commits.
  3. Confirm the repository is public/accessible so the API returns real data.
  4. Update badges after master→main or other branch renames.

Example fix

// before
/badge/bitbucket/last-commit/user/repo/old-branch
// after
/badge/bitbucket/last-commit/user/repo/main
Defensive patterns

Strategy: validation

Validate before calling

const res = await fetch(
  `https://api.bitbucket.org/2.0/repositories/${user}/${repo}/commits/${branch}`
)
if (!res.ok) throw new Error(`Branch '${branch}' not found on ${user}/${repo}`)
const data = await res.json()
if (!data.values?.length) throw new Error('No commits on this branch/path')

Try / catch

try {
  return await lastCommitBadge({ user, repo, branch })
} catch (e) {
  if (e instanceof NotFound) return renderBadge('no commits')
  throw e
}

Prevention

When it happens

Trigger: Requesting the last-commit badge for a Bitbucket repo/branch/path combination where the commits API returns an empty values array — typically a nonexistent branch name or a path filter that no commit touches.

Common situations: Branch renamed or deleted (e.g. master → main migration); typo in the branch parameter; path parameter pointing at a file/dir that does not exist on that branch; empty repository.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of badges/shields@766fd8bc89 (2026-08-30). Data as JSON: /api/errors/b8f45c1a62c3a0ad. Report an issue: GitHub.