{"record":{"id":"7bfda3206427774d","repo":"badges/shields","slug":"license-not-found-7bfda3","errorCode":null,"errorMessage":"license not found","messagePattern":"license not found","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"services/packagist/packagist-license.service.js","lineNumber":76,"sourceCode":"    },\n  }\n\n  static defaultBadgeData = {\n    label: 'license',\n  }\n\n  transform({ json, user, repo }) {\n    const packageName = this.getPackageName(user, repo)\n\n    const versions = BasePackagistService.expandPackageVersions(\n      json,\n      packageName,\n    )\n\n    const version = this.findLatestRelease(versions)\n    const license = version.license\n    if (!license) {\n      throw new NotFound({ prettyMessage: 'license not found' })\n    }\n\n    return { license }\n  }\n\n  async handle({ user, repo }, { server }) {\n    const json = await this.fetch({ user, repo, schema, server })\n\n    const { license } = this.transform({ json, user, repo })\n\n    return renderLicenseBadge({ license })\n  }\n}\n","sourceCodeStart":58,"sourceCodeEnd":90,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/packagist/packagist-license.service.js#L58-L90","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before (composer.json)\n{ \"name\": \"vendor/pkg\", \"description\": \"...\" }\n// after\n{ \"name\": \"vendor/pkg\", \"description\": \"...\", \"license\": \"MIT\" }","handlingStrategy":"validation","validationCode":"const latest = await getPackagistLatestRelease(user, repo)\nif (!latest || !Array.isArray(latest.license) || latest.license.length === 0) throw new Error('Latest release has no license declared in composer.json')","typeGuard":"function hasLicense(release) {\n  return typeof release === 'object' && release !== null && Array.isArray(release.license) && release.license.length > 0\n}","tryCatchPattern":"try {\n  const badge = await license(user, repo)\n} catch (e) {\n  if (e instanceof NotFound && e.message === 'license not found') return { label: 'license', message: 'unknown', color: 'lightgrey' }\n  throw e\n}","preventionTips":["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"],"tags":["packagist","license","not-found","composer"],"backgroundTag":"resource-not-found","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}