{"record":{"id":"4c182ecc1a672138","repo":"badges/shields","slug":"not-found","errorCode":null,"errorMessage":"not found","messagePattern":"not found","errorType":"exception","errorClass":"NotFound","httpStatus":404,"severity":"error","filePath":"services/ansible/ansible-role.service.js","lineNumber":46,"sourceCode":"      },\n    },\n  }\n\n  static defaultBadgeData = { label: 'role downloads' }\n\n  async fetch({ namespace, name }) {\n    const url = 'https://galaxy.ansible.com/api/v1/roles/'\n    return this._requestJson({\n      url,\n      schema: ansibleRoleSchema,\n      options: { searchParams: { namespace, name, limit: 1 } },\n    })\n  }\n\n  async handle({ namespace, name }) {\n    const json = await this.fetch({ namespace, name })\n    if (json.results.length === 0) {\n      throw new NotFound({ prettyMessage: 'not found' })\n    }\n    return renderDownloadsBadge({ downloads: json.results[0].download_count })\n  }\n}\n","sourceCodeStart":28,"sourceCodeEnd":51,"githubUrl":"https://github.com/badges/shields/blob/766fd8bc89a90b8534dc573ab72dec30215ab1ec/services/ansible/ansible-role.service.js#L28-L51","documentation":"The Ansible role service fetches role metadata from the Ansible Galaxy API and throws NotFound with prettyMessage 'not found' when the response's results array is empty. This is Shields' way of rendering a 'not found' badge when the requested namespace/name does not match any role on Galaxy.","triggerScenarios":"this.fetch({ namespace, name }) succeeds (HTTP 200) but json.results.length === 0 — the Galaxy search by namespace/name returns no matching role.","commonSituations":"Typo in the role namespace or name in the badge URL, role deleted/renamed on Ansible Galaxy, role not yet published/imported (Galaxy import pending), asking for a role hosted under a different namespace.","solutions":["Verify the namespace/name in the badge URL against the role's page on galaxy.ansible.com.","Check whether the role was renamed or removed from Galaxy.","Wait for the Galaxy import to complete for newly published roles.","Use the correct namespace (author) — role names are not unique across namespaces."],"exampleFix":"// before\n/api/v1/roles/?namespace__name=myusr&name=myrole  -> results: [] -> NotFound\n// after (correct namespace)\n/api/v1/roles/?namespace__name=correctuser&name=myrole  -> results: [{ download_count: 42 }]","handlingStrategy":"validation","validationCode":"// verify the role exists before requesting the badge\ncurl -s \"https://galaxy.ansible.com/api/v1/roles/?namespace__name=NS&name=NAME\" | jq '.results | length'","typeGuard":"function roleExists(json) { return Array.isArray(json?.results) && json.results.length > 0 }","tryCatchPattern":"try {\n  const badge = await service.handle({ namespace, name })\n} catch (err) {\n  if (err.name === 'NotFound') return renderNotFoundBadge()\n  throw err\n}","preventionTips":["Verify namespace/name against the role's Galaxy page before embedding the badge.","Account for roles being renamed or removed.","Wait for Galaxy import to finish for new roles.","Remember names are scoped per namespace."],"tags":["not-found","ansible","galaxy","upstream"],"backgroundTag":"upstream-resource-not-found","analyzedSha":"766fd8bc89a90b8534dc573ab72dec30215ab1ec","analyzedAt":"2026-08-30T01:40:27.499Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}