badges/shields · error · NotFound
license not found
Error message
license not found
What it means
This NotFound error comes from the Packagist license badge transform. After finding the latest release with findLatestRelease, it reads that release's 'license' field; when the release metadata has no license array (empty/missing), the badge cannot be rendered.
Source
Thrown at services/packagist/packagist-license.service.js:76
},
}
static defaultBadgeData = {
label: 'license',
}
transform({ json, user, repo }) {
const packageName = this.getPackageName(user, repo)
const versions = BasePackagistService.expandPackageVersions(
json,
packageName,
)
const version = this.findLatestRelease(versions)
const license = version.license
if (!license) {
throw new NotFound({ prettyMessage: 'license not found' })
}
return { license }
}
async handle({ user, repo }, { server }) {
const json = await this.fetch({ user, repo, schema, server })
const { license } = this.transform({ json, user, repo })
return renderLicenseBadge({ license })
}
}
View on GitHub (pinned to 766fd8bc89)
Solutions
- Add a 'license' key (e.g. "license": "MIT") to the package's composer.json and push a new release
- Check the package's composer.json on packagist.org to confirm the license field is genuinely missing
- Remove the license badge if the package intentionally has no license
- Pin the badge to a specific older version that does declare a license
Example fix
// before (composer.json)
{ "name": "vendor/pkg", "description": "..." }
// after
{ "name": "vendor/pkg", "description": "...", "license": "MIT" } Defensive patterns
Strategy: validation
Validate before calling
const latest = await getPackagistLatestRelease(user, repo)
if (!latest || !Array.isArray(latest.license) || latest.license.length === 0) throw new Error('Latest release has no license declared in composer.json') Type guard
function hasLicense(release) {
return typeof release === 'object' && release !== null && Array.isArray(release.license) && release.license.length > 0
} Try / catch
try {
const badge = await license(user, repo)
} catch (e) {
if (e instanceof NotFound && e.message === 'license not found') return { label: 'license', message: 'unknown', color: 'lightgrey' }
throw e
} Prevention
- Always declare a 'license' key in composer.json
- Check the license field on packagist.org before adding a license badge
- Fall back to an 'unknown license' badge instead of failing
When it happens
Trigger: Requesting a license badge for a package whose latest release on Packagist has a missing or empty license field in its composer.json (no 'license' key declared).
Common situations: Open-source packages whose authors never added a license key to composer.json; private/unlicensed packages; a newly published release that dropped the license field.
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/7bfda3206427774d.
Report an issue: GitHub.